maven打包自动配置数据库链接信息

 pom.xml加入下面代码 
<profiles>
        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <profiles.active>dev</profiles.active>
                <app.code>task</app.code>
                <database.className>com.mysql.jdbc.Driver</database.className>
                <database.url>jdbc:mysql://127.0.0.1:3306/abc_test</database.url>
                <database.username>root</database.username>
                <database.password>root</database.password>
            </properties>
        </profile>
    </profiles>
    
  <build>
          <finalName>task</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        
    </build>
 数据库连接配置:
<property name="driverClassName" value="${database.className}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" /> <property name="password" value="${database.password}" />
 

相关内容推荐