关于阿里的自动打包工具有这么几个地方要配置
1.在项目的pom.xml中引入自动打包工具的插件,如下
<plugin>
<groupId>com.alibaba.citrus.tool</groupId>
<artifactId>autoconfig-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<!-- 配置在package phase中运行maven-autoconfig-plugin的autoconfig goal -->在打包的时候才运行这个插件
<execution>
<goals>
<goal>autoconfig</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
2. auto-config.xml 文件,这个配置文件放在META_INF下面
<?xml version="1.0" encoding="utf-8"?>
<config description="自动配置">
<group name="datasource">
<property name="bieyang.datasource.jdbc.url" defaultValue="jdbc:mysql://localhost:3306/bieyang" description="数据库连接地址"/>
<property name="bieyang.datasource.jdbc.username" defaultValue="root" description="数据库用户名"/>
<property name="bieyang.datasource.jdbc.password" defaultValue="root" description="数据库密码"/>
</group>
<group name="web">
<property name="bieyang.popo.web.server.url" defaultValue="http://localhost:8080" description="网站服务器地址"/>
<property name="bieyang.popo.static.server.url" defaultValue="http://localhost:8080" description="静态服务器地址"/>
<property name="bieyang.popo.photo.server.url" defaultValue="http://localhost:8080" description="静态图片服务器地址"/>
</group>
<group name="logger">
<property name="bieyang.logger.home.dir" defaultValue="C:/output/logs/bieyang" description="日志文件输出位置"/>
<property name="bieyang.logger.production" defaultValue="DEV" description="日志文件输出模式"/>
</group>
<group name="swagger">
<property name="documentation.services.version" defaultValue="1.0" description="API版本"/>
<property name="documentation.services.basePath" defaultValue="http://localhost:8080/" description="API访问地址"/>
</group>
<script>
<generate template="WEB-INF/classes/autoconf/bieyang-config.properties.vm" destfile="WEB-INF/classes/bieyang-config.properties" charset="UTF-8" />
</script>
</config>
注意:上面的 script 子标签,将根据 bieyang-config.properties.vm模板文件的内容去生成打包好的文件中的 WEB-INF/classes/bieyang-config.properties 文件。
下面我们编写 bieyang-config.properties.vm 模板文件。
3.模板文件bieyang-config.properties.vm
bieyang.datasource.jdbc.url=${bieyang_datasource_jdbc_url}
bieyang.datasource.jdbc.username=${bieyang_datasource_jdbc_username}
bieyang.datasource.jdbc.password=${bieyang_datasource_jdbc_password}
bieyang.popo.web.server.url=${bieyang_popo_web_server_url}
bieyang.popo.static.server.url=${bieyang_popo_static_server_url}
bieyang.popo.photo.server.url=${bieyang_popo_photo_server_url}
bieyang.logger.home.dir=${bieyang_logger_home_dir}
bieyang.logger.production=${bieyang_logger_production}
bieyang.sms.alidayu.appkey=${bieyang_sms_alidayu_appkey}
bieyang.sms.alidayu.secret=${bieyang_sms_alidayu_secret}
bieyang.im.neteaseim.appkey=${bieyang_im_neteaseim_appkey}
bieyang.im.neteaseim.secret=${bieyang_im_neteaseim_secret}
4.还有就是antx.properties这个配置文件了
这个配置文件默认是在C:\Users\Administrator
在本地环境中,项目启动时会根据autoconfig文件生成或者修改 antx.properties文件(修改主要是添加名值对,不会覆盖原来的名值对)。如果antx.properties文件中没有对应的name,则会把antoconfig.xml中的name:defaultValue复制到antx.properties中,即直接使用那些defaultvalue。这是defaultValue的主要作用。
bieyang.aliyun.accessId = LTAIfV9AURz9LXxP
bieyang.aliyun.accessSecret = 0UCHO1sCQgdilOfoSu8Qvf6tZfPf7r
bieyang.datasource.jdbc.password = 123
bieyang.datasource.jdbc.url = jdbc:mysql://localhost:3306/ssyer?useUnicode=true&characterEncoding=UTF-8
bieyang.datasource.jdbc.username = root
bieyang.im = .neteaseim.secret=0dd47c7ead2e
bieyang.im.neteaseim.appkey = 66fd648b21b81a5cd921f8c1d09d28ec
bieyang.im.neteaseim.secret = 47fa1adbb947
bieyang.lbs.amap.key = 6bcc18ed2f91d9cab4e1442bbecd1330
bieyang.lbs.amap.offerOrder.radius = 50000
bieyang.lbs.amap.offerOrder.tableid = 5808597a7bbf19717e8142de
bieyang.lbs.amap.workplace.tableid = 583ba3b7305a2a4ab5989e9a
bieyang.logger.home.dir = C:/output/logs/bieyang
bieyang.logger.production = DEV
bieyang.pay.lianlianpay.md5Key = 201408071000001546_test_20140815
bieyang.pay.lianlianpay.notifyUrl = http://localhost:8080/s/pay/lianlian_notify
bieyang.pay.lianlianpay.oidPartner = 201610101001151522
bieyang.pay.lianlianpay.privateKey = MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJnlpZNc0KEN4OV5uAGZoaPPVOF69lWJfpMST0pCaSPnq6PKCugbNpActo0u492m2mMKRNNjxK3rgmKcRq91y7fDO9oWjg39MWHdKeexKLVH3fBcD+gPiH6yzN3f4x/KXuCr2nsLJDUzWsn6sE5sn4AzmF/yRgKxz1mNe0oTfAgMBAAECgYEAh+9w8Vlqbtfzbr606bTqMedQ8lnKfIOWahIi0gS2GUQucZItcQhHiPrbh/un4Zrf72B6TmI0a+uanE8Gh4v0YagMjEMq9qCE/UjZBnNx8hdRcBA+5WT7gt4Cr2bazg1awb7cAYkYN2S6RHl07dt9Eez8DIoHAiQc5Gfti94tnwECQQDKQIzN57Za5wbnTqruN9CoNd3MBiir8+akUVW9UCRVnJqPhjGY8boHm962JcUqlRiUZ8AEcJ9YPfec1e32VO5tAkEAwstxhSE76oX6qyGBTW7NVYh5QcD6x6zIpPIVZaextWLANwvnp27DeVPB1ygr5i5/z+79eKkOoyi+jEMfA+wJBALIc5KNUgwhM2oyLgAaoCs6IGZradajw81YT9tDwqf7nGkp5IGaTwoN+5kQ8wQU+JlZThAuk7v80G0L4N0cvBoUCQAC4I5ksQD5jdEOBgiq5CAUS1e/KOKLYHn2Nb0rKzbsvvCn330kc/ZhIuA50PNscI0PCuXHqiPx693qXpnB/bFUCQGTqtK2GIE/AfxhW6ARy0DPkzunfvD5wKTQDtIKQ0Sq29PoIV/bfrvmPvSau6Lyvs8f10igzZ1LQXvubqVGQd5E=
bieyang.pay.lianlianpay.signType = RSA
bieyang.pay.lianlianpay.urlReturn = http://localhost:8080/s/account/point_url_return
bieyang.pay.lianlianpay.ytPubKey = MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSS/DiwdCf/aZsxxcacDnooGph3d2JOj5GXWi+q3gznZauZjkNP8SKl3J2liP0O6rU/Y/29+IUe+GTMhMOFJuZm1htAtKiu5ekW0GlBMWxf4FPkYlQkPE0FtaoMP3gYfh+OwI+fIRrpW3ySn3mScnc6Z700nU/VYrRkfcSCbSnRwIDAQAB
bieyang.popo.photo.server.url = http://img.ssyer.com
bieyang.popo.static.server.url = http://localhost:8080
bieyang.popo.web.server.url = http://localhost:8080
bieyang.sms.alidayu.appkey = 23745605
bieyang.sms.alidayu.secret = 549bd07ab82c2639ffadf0733b07f739
documentation.services.basePath = http://localhost:8080/
documentation.services.version = 1.0