网站 tool.liyongqiang.com 就是用的是这个
maven配置多环境设置
经常为环境不一样而烦恼
所有打算改掉
配置 profile 放在 build 外面
<profiles> <profile> <id>dev</id> <properties> <package.environment>dev</package.environment> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>env</id> <properties> <package.environment>env</package.environment> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> <profile> <id>test</id> <properties> <package.environment>test</package.environment> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> </profiles>
配置build及项目打包后的虚拟环境
<build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*.*</include> </includes> <excludes> <exclude>dev/*</exclude> <exclude>env/*</exclude> <exclude>test/*</exclude> </excludes> </resource> <resource> <directory>src/main/resources/${profiles.active}</directory> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <configuration> <skip>false</skip> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> <warName>${project.artifactId}</warName> <archive> <addMavenDescriptor>false</addMavenDescriptor> </archive> <webResources> <!-- 不同的环境,使用不同的配置文件 --> <resource> <directory>src/main/resources/${package.environment}</directory> <targetPath>WEB-INF/classes/properties</targetPath> <filtering>true</filtering> </resource> </webResources> </configuration> </plugin> </plugins> </build>
在jeesite中 需要修改 xml中配置 把 对应的(开发,正式环境)数据库 修改 成 上面配置的 虚拟路径
不懂可以留言 活着 网上查下