Skip to content

Instantly share code, notes, and snippets.

@jdonee
Last active August 8, 2018 14:12
Show Gist options
  • Save jdonee/6238531 to your computer and use it in GitHub Desktop.
Save jdonee/6238531 to your computer and use it in GitHub Desktop.
portable-config-maven-plugin
clean package -Dmaven.test.skip=true -Denv=proc
[WARNING] No portable config file is provided, skipping running.
pom.xml
--------------------------------------------------------------------------------------------
<profiles>
<profile>
<id>proc</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>env</name>
<value>proc</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<!-- 参数配置插件 -->
<groupId>com.juvenxu.portable-config-maven-plugin</groupId>
<artifactId>portable-config-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>replace-package</goal>
</goals>
</execution>
</executions>
<configuration>
<portableconfig>src/main/portable/proc.xml</portableconfig>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
src/main/portable/proc.xml
---------------------------------------------------------------------------------------------
<!--?xml version="1.0" encoding="utf-8" ?-->
<portable-config>
<!-- 数据库篇配置-->
<config-file path="WEB-INF/classes/spring-jdbc.properties">
<replace key="jdbc.driver">com.mysql.jdbc.Driver</replace>
<replace key="jdbc.url">jdbc:mysql://192.168.1.129:3306/iotek?useUnicode=true<![CDATA[&amp;]]>characterEncoding=utf8</replace>
<replace key="jdbc.username">iotek</replace>
<replace key="jdbc.password">iotek</replace>
<replace key="jdbc.pool.maxIdle">20</replace>
<replace key="jdbc.pool.maxActive">100</replace>
</config-file>
<!-- 日志配置 -->
<config-file path="WEB-INF/classes/log4j.properties">
<replace key="log4j.rootLogger">WARN, stdout</replace>
</config-file>
<!-- struts配置 -->
<config-file path="WEB-INF/classes/struts.xml">
<replace xpath="/struts/constant[@name='struts.devMode']">false</replace>
</config-file>
<!-- web.xml配置 -->
<config-file path="WEB-INF/web.xml">
<replace xpath="/web-app/context-param[@param-name='spring.profiles.default']">production</replace>
</config-file>
</portable-config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment