<转>用maven的profile构建生产环境,STG环境下不同名不同内容的jar包

原链接:http://blog.csdn.net/thestoryoftony/article/details/8746446

  在pom.xml中首先定义一个标志不同环境的id

         

[html] view plaincopyprint?
       <properties> 
    <profile.id>staging</profile.id> 
</properties> 

建立如下的profile,构建不同环境下的不同内容
[html] view plaincopyprint?
<profiles> 
      <profile> 
          <id>production</id> 
          <properties> 
              <maven.test.skip>true</maven.test.skip> 
              <profile.id>production</profile.id> 
          </properties> 
          <build> 
              <resources> 
                  <resource> 
                      <directory>environment/production/src/main/resources</directory> 
                  </resource> 
                  <resource> 
                      <directory>src/main/resources</directory> 
                      <excludes> 
                          <exclude>**/resources.properties</exclude> 
                      </excludes> 
                  </resource> 
              </resources> 
          </build> 
      </profile> 
      <profile> 
          <id>staging</id> 
          <properties> 
              <maven.test.skip>true</maven.test.skip> 
              <profile.id>staging</profile.id> 
          </properties> 
          <build> 
              <resources> 
                  <resource> 
                      <directory>environment/staging/src/main/resources</directory> 
                  </resource> 
                  <resource> 
                      <directory>src/main/resources</directory> 
                      <excludes> 
                          <exclude>**/resources.properties</exclude> 
                      </excludes> 
                  </resource> 
              </resources> 
          </build> 
      </profile> 
  </profiles> 

修改fullName,让其中加入不同环境的标志符
[html] view plaincopyprint?
<finalName>${profile.id}-publiclib-${project.version}</finalName> 

这样编译出来的jar包中天然带有不同环境的标志,易于区分。

猜你喜欢

转载自yingbin920.iteye.com/blog/1931770