一直猜想是打包阶段的问题,找了好久找到这个:https://blog-gkishorapps.rhcloud.com/2014/05/removing-white-space-in-jsps-for-webapps-using-maven/ (翻墙才行)
直接上代码:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<useCache>true</useCache>
</configuration>
<executions>
<execution>
<id>prepare-war</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${project.build.directory}</basedir>
<filesToInclude>${project.artifactId}/WEB-INF/jsp/**/*.jsp</filesToInclude>
<token>>\s*<</token>
<value>><</value>
<regexFlags>
<regexFlag>MULTILINE</regexFlag>
</regexFlags>
</configuration>
</plugin>
</plugins>
</build>
主要是让war-plugin拷贝之后再替换
推荐使用 http://www.impress.pw 替代国内没法使用谷歌的情况