问题描述
在maven打war包时,pom.xml自定义的properites 可以打到*.properties文件中,但是在*.jsp中引用自定义变量无法打入,求一份可以打到jsp中的pom.xml自定义变量是在pom.xml的 profile properties 中定义的,比如以下域名:图片域名、样式域名等等。在jsp页面中有引入样式形如<link href="${profile.xxx.domain}/a/b/c.css" rel="stylesheet" type="text/css" />profile.xxx.domain 实在 pom.xml 中 <profile> <id>development-ws</id> <properties><profile.xxx.domain>http://www.jd.com/</profile.xxx.domain> </properties> </profile>
解决方案
给你个完整的看看:<build><resources><resource><directory>src/main/resources</directory><includes><include>*.*</include><include>**/*.*</include></includes><filtering>true</filtering></resource></resources><plugins><!-- compiler插件, 设定JDK版本 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.0</version><configuration><source>${jdk.version}</source><target>${jdk.version}</target><showWarnings>true</showWarnings></configuration></plugin><!-- war打包插件, 设定war包名称不带版本号 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.3</version><configuration><warName>${project.artifactId}</warName><webResources><resource><directory>src/main/webapp</directory><includes><include>*.*</include><include>**/*.*</include></includes><filtering>true</filtering></resource></webResources></configuration></plugin></plugins></build>
解决方案二:
推荐尝试下 gradle !
解决方案三:
检查你的pom有没有war打包插件,如下:<!-- war打包插件, 设定war包名称不带版本号 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.3</version><configuration><warName>${project.artifactId}</warName><webResources><resource><directory>src/main/webapp</directory><includes><include>*.*</include><include>**/*.*</include></includes><filtering>true</filtering></resource></webResources></configuration></plugin>