Maven3 package时报 'version' contains an expression but should be a constant
2017-12-04 22:13
1101 查看
父pom文件:
子Module
package web工程时报 'version' contains an expression but should be a constant这个错误提示,这是因为Maven3 不允许出现version为非常量值的情况。
那么就将版本号改成常量后可以正常打包:
父pom文件:
子Module
如果更新版本号一个文件一个文件的去改太麻烦,可以用以下命令一次性更新版本号:
>mvn versions:set -DnewVersion=0.0.2-SNAPSHOT
>mvn versions:update-child-modules
更新的父及子Module的版本号都改成了0.0.2-SNAPSHOT.
Maven还会生成一个pom.xml.versionsBackup的备份文件。
提交更新:
>mvn versions:commit
<modelVersion>4.0.0</modelVersion> <groupId>com.wey</groupId> <artifactId>WEY</artifactId> <version>${com.wey.version}</version> <packaging>pom</packaging>
子Module
<modelVersion>4.0.0</modelVersion> <groupId>com.wey</groupId> <artifactId>WEY</artifactId> <version>${com.wey.version}</version> <packaging>pom</packaging>
package web工程时报 'version' contains an expression but should be a constant这个错误提示,这是因为Maven3 不允许出现version为非常量值的情况。
那么就将版本号改成常量后可以正常打包:
父pom文件:
<modelVersion>4.0.0</modelVersion> <groupId>com.wey</groupId> <artifactId>WEY</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging>
子Module
<parent> <groupId>com.wey</groupId> <artifactId>WEY</artifactId> <version>0.0.1-SNAPSHOT</version> <relativePath>../WEY/pom.xml</relativePath> </parent> <artifactId>WEY.WebApp</artifactId> <packaging>war</packaging> <name>WEY.WebApp Maven Webapp</name> <url>http://maven.apache.org</url>
如果更新版本号一个文件一个文件的去改太麻烦,可以用以下命令一次性更新版本号:
>mvn versions:set -DnewVersion=0.0.2-SNAPSHOT
>mvn versions:update-child-modules
更新的父及子Module的版本号都改成了0.0.2-SNAPSHOT.
<modelVersion>4.0.0</modelVersion> <groupId>com.wey</groupId> <artifactId>WEY</artifactId> <version>0.0.2-SNAPSHOT</version> <packaging>pom</packaging> <parent> <groupId>com.wey</groupId> <artifactId>WEY</artifactId> <version>0.0.2-SNAPSHOT</version> <relativePath>../WEY/pom.xml</relativePath> </parent> <artifactId>WEY.WebApp</artifactId> <packaging>war</packaging> <name>WEY.WebApp Maven Webapp</name> <url>http://maven.apache.org</url>
Maven还会生成一个pom.xml.versionsBackup的备份文件。
提交更新:
>mvn versions:commit
相关文章推荐
- maven2 up to maven3的'version' contains an expression but should be a constant
- 'version' contains an expression but should be a constant
- mm_The type of the expression must be an array type but it resolved to List
- The type of the expression must be an array type but it resolved to Point
- an software engineer should be
- J-LINK突然不能下载(错误:JLink Warning: RESET (pin 15) high, but should be low. Please check target)
- python3爬虫问题 POST data should be bytes or an iterable of bytes
- You should be the top dog in your department and always keep an eye on the outside world.
- net.paoding.analysis.exception.PaodingAnalysisException: dic home should not be a file, but a directory!
- Layout state should be one of 100 but it is 10的问题
- Variable used in lambda expression should be final or effectively final
- “JTAG Warning: T-bit of XPSR is 0 but should be 1. Changed to 1.” 解决方案
- Fundamental Book, but should be last read
- JBOSS 启动报 [ClientGmsImpl] suspect() should not be invoked on an instance of org.jgroups.protocols.pbcast.ClientGmsImpl
- dic home should not be a file, but a directory!
- python3 “POST data should be bytes or an iterable of bytes...”的解决方法
- 'PIO_STACK_LOCATION' : illegal use of this type as an expression
- iOS利用Application Loader打包提交到App Store时遇到错误The filename 未命名.ipa in the package contains an invalid character(s). The valid characters are:A-Z ,a-z,0-9,dash,period,underscore,but the name cannot start w
- React Native JSX value should be expression or a quoted JSX text.
- python3.x执行post请求时报错“POST data should be bytes or an iterable of bytes...”的解决方法