maven替换静态资源文件

网站dev,uat,pdt环境的域名不同,在页面写死?

java里面可以通过maven的profile->properties文件->spring注入@Value("${basePath}")

private String basePath; 

但是静态资源怎么替换呢?

maven:把webapp拷贝到resource目录下,编译时候直接就替换了

<profile>
   <id>pdt</id>
   <activation>
      <activeByDefault>true</activeByDefault>
   </activation>
   <properties>
      <ds.driverClass>com.mysql.jdbc.Driver</ds.driverClass>
      <ds.jdbcUrl>jdbc:mysql://192.168.4.203:3306/stw?characterEncoding=UTF8&amp;amp;zeroDateTimeBehavior=convertToNull</ds.jdbcUrl>
      <ds.username>root</ds.username>
      <ds.password>1qazxsw2</ds.password>

      <ds.maximumConnectionCount>100</ds.maximumConnectionCount>
      <ds.minimumConnectionCount>25</ds.minimumConnectionCount>
      <ds.simultaneousBuildThrottle>10</ds.simultaneousBuildThrottle>
      <ds.houseKeepingTestSql>select 1 from dual</ds.houseKeepingTestSql>
      <ds.testBeforeUse>true</ds.testBeforeUse>
      <ds.alias></ds.alias>
      <!--<ds.alias><![CDATA[<property name="alias" value="alias_web_11" />]]></ds.alias>-->
<webapp.context>stw.brmlion.cn:19530</webapp.context>
      <!-- ## spring-security settings start -->
      <!-- ## cas server login -->
<security.cas.username>stw</security.cas.username>
      <security.cas.password>/F4DjTilcDIIVEHn/nAQsA==</security.cas.password>
      <security.cas.defaultCasIndex>/cas/login.html</security.cas.defaultCasIndex>
      <business.server.url>http://www.1shitou.com</business.server.url>
      <defaultTargetUrl>${business.server.url}/index.html</defaultTargetUrl>
      <cas.server.url>https://cas.1shitou.cn</cas.server.url>
      <cas.path.name></cas.path.name>
      <security.cas.server_login>${cas.server.url}${cas.path.name}/login</security.cas.server_login>
      <!-- ## cas client j_spring_cas_security_check -->
<security.cas.client_after_login_check>${business.server.url}/j_spring_cas_security_check</security.cas.client_after_login_check>
      <!-- ## cas server ticket validator -->
<security.cas.server_ticket_validator>${cas.server.url}${cas.path.name}</security.cas.server_ticket_validator>
      <!-- ## cas server logout -->
<security.cas.server_logout>${cas.server.url}${cas.path.name}/logout?service=${business.server.url}</security.cas.server_logout>
      <!-- ## spring-security settings end -->

<platform_business.server.url>http://www.1shitou.cn:8880</platform_business.server.url>
      <platform_business.registerUrl>${platform_business.server.url}/Regist/registor.html</platform_business.registerUrl>
      <basePath>http://www.1shitou.com</basePath>

      <!-- memcache config -->
<memcache.serverIpAndPort1><![CDATA[<value>172.16.111.11:11211</value>]]></memcache.serverIpAndPort1>
      <memcache.serverWeight1><![CDATA[<value>1</value>]]></memcache.serverWeight1>
      <memcache.serverIpAndPort2><![CDATA[<value>172.16.111.12:11213</value>]]></memcache.serverIpAndPort2>
      <memcache.serverWeight2><![CDATA[<value>1</value>]]></memcache.serverWeight2>

      <!-- auth config -->
<auth.paymentBankApi>https://epay.brmlion.com/payment/ccb/sendToBank</auth.paymentBankApi>
      <auth.paymentNoApi>https://epay.brmlion.com/payment/ccb/productPaymentNo</auth.paymentNoApi>
      <auth.payServerIp>223.100.7.112</auth.payServerIp>
      <auth.payPlatformNo>03</auth.payPlatformNo>
      <auth.bankDesKey>3CZdB/5tqLk=</auth.bankDesKey>
      <auth.stock.search.url>http://new.1shitou.com/jc/</auth.stock.search.url>

      <!-- chatroom config -->
<stw.chatroom.server.uri>http://172.16.111.10:8080/chatroom-server-web</stw.chatroom.server.uri>

      <!-- log config -->
<logger.rootCategory>INFO,stdout</logger.rootCategory>
      <logger.dbLevel>INFO,DB</logger.dbLevel>
      <logger.userInfoLevel>INFO,userinfo</logger.userInfoLevel>
      <logger.level>INFO</logger.level>
      <logger.file>c:/logs/${project.artifactId}.log</logger.file>
      <logger.db.file>c:/logs/${project.artifactId}-dbService.log</logger.db.file>

      <!-- solr config -->
<stw.solr.teacher.host>http://172.16.111.13:8088/solr/teacher</stw.solr.teacher.host>
      <stw.solr.video.host>http://172.16.111.13:8088/solr/video</stw.solr.video.host>

      <!-- statistic config -->
<stw.statistic.add.uri>http://172.16.111.13:8060/statistic-web/statistic/add.json</stw.statistic.add.uri>
      <stw.statistic.add.filepath>/tmp/mqfile/</stw.statistic.add.filepath>

      <!-- video config -->
<stw.video.adv.cdn>http://domhttp.kksmg.com/2016/11/21/h264_450k_mp4_67b478095920d7ec10e96c84cbdf00f2_ncm.mp4</stw.video.adv.cdn>
      <stw.video.adv.stw>http://js.1shitou.com/video.flv</stw.video.adv.stw>
      <stw.video.check.time>300</stw.video.check.time>

      <stw.host.old>http://new.1shitou.com:8080</stw.host.old>
      <stw.host>http://www.1shitou.com:8080</stw.host>

      <!-- tomcat session cache config -->
<session.redis.ip>172.16.254.117</session.redis.ip>
      <session.redis.port>6379</session.redis.port>
      <session.redis.password>redhat</session.redis.password>
      <session.redis.database>1</session.redis.database>

      <payment.client.localXRealIp>59.46.52.54</payment.client.localXRealIp>
      <payment.service.url>https://www.brmlion.com/payment/ccb/</payment.service.url>

      <!-- 2017-05-02 新增配置 -->
<messageSender.brokerURL>tcp://192.168.0.204:61616</messageSender.brokerURL>
      <messageSender.destination>StoneWebService1.1</messageSender.destination>

      <host.image>http://images.1shitou.com</host.image>
      <host.css>http://${webapp.context}</host.css>
      <adpage.file>http://${webapp.context}</adpage.file>
      <payment.bankApi>https://epay.1shitou.com/payment/ccb/sendToBank</payment.bankApi>
      <payment.noApi>https://epay.1shitou.com/payment/ccb/productPaymentNo</payment.noApi>
      <payment.serverIp>103.243.254.252</payment.serverIp>
      <payment.platformNo>03</payment.platformNo>
      <payment.bankDesKey>3CZdB/5tqLk=</payment.bankDesKey>
      <stock.searchUrl>http://new.1shitou.com/jc/</stock.searchUrl>
      <cookie.domain>.1shitou.com</cookie.domain>

      <redirect.login.defaultUrl>/index.html</redirect.login.defaultUrl>
      <redirect.login.failureUrl>/sso/login.html</redirect.login.failureUrl>
      <sso.username>stw</sso.username>
      <sso.password>/F4DjTilcDIIVEHn/nAQsA==</sso.password>
      <sso.serverUrl>http://www.brmlion.cn:8880</sso.serverUrl>
   </properties>
</profile>
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-resources-plugin</artifactId>
   <!--resources compile pages-->
<executions>
      <execution>
         <id>copy-resources</id>
         <!-- here the phase you need -->
<phase>validate</phase>
         <goals>
            <goal>copy-resources</goal>
         </goals>
         <configuration>
            <encoding>utf-8</encoding>
            <outputDirectory>${basedir}/src/main/webapp</outputDirectory>
            <overwrite>true</overwrite>
            <resources>
               <resource>
                  <directory>src/main/resources/webapp</directory>
                  <filtering>true</filtering>
               </resource>
            </resources>
         </configuration>
      </execution>
   </executions>
</plugin>


猜你喜欢

转载自bigdragon.iteye.com/blog/2373657