一、Maven项目资源文件创建

Maven项目常分开发环境、测试环境、生产环境,会出各种包,为了避免配置文件的反复修改,因此在打maven包时候,进行资源文件修改。 配置如下: ### 1、Pom配置 <!-- maven build 使用filter资源文件,进行替换 --> llp-boss src/main/resources true .properties logback.xml src/main/resources false .properties logback.xml

<!-- 获取filter -->
<filters>
  <filter>${resource.filter}</filter>
</filters>

<plugins>
  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <configuration>
      <charset>UTF-8</charset>
      <port>8080</port>
      <path>/boss</path>
      <uriEncoding>UTF-8</uriEncoding>
      <systemProperties>
        <druid.log.stmt.executableSql>true</druid.log.stmt.executableSql>
      </systemProperties>
    </configuration>
  </plugin>
</plugins>

<!-- 定义profiles --> dev true filters/dev.properties test filters/test.properties production filters/production.properties

2、src/main/resources 要替换的资源文件

src/main/resources/conf/db.properties ======db.properties jdbc.datasource=com.mchange.v2.c3p0.ComboPooledDataSource jdbc.driverClass=com.mysql.jdbc.Driver jdbc.url=${jdbc.url} jdbc.username=${jdbc.username} jdbc.password=${jdbc.password}

jdbc.minPoolSize=10 jdbc.maxPoolSize=50 jdbc.autoCommit=false