maven2 up to maven3的'version' contains an expression but should be a constant
2015-02-05 15:47
274 查看
在Maven2时,为了保障版本一致,一般之前我们的做法时:
Parent Pom中<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cy.nad.cyg</groupId> <artifactId>pay</artifactId> <version>${myproject.version}</version> <packaging>pom</packaging> <name>pay-parent</name> <modules> <module>pay-web</module> <module>pay-manage</module> <module>pay-dao</module> </modules> <properties> <myproject.version>3.0.2</myproject.version>
在子module中
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>pay</artifactId> <groupId>cy.nad.cyg</groupId> <version>${myproject.version}</version> </parent> <artifactId>pay-web</artifactId> <packaging>war</packaging> <name>pay-web</name> <properties> <sso-client.version>0.0.3</sso-client.version> </properties> <dependencies> <dependency> <groupId>cy.nad.cyg</groupId> <artifactId>pay-dao</artifactId> <version>${project.version}</version> </dependency>
但是升级到maven3之后,会出这个问题:
[WARNING] Some problems were encountered while building the effective model for cy.nad.cyg:pay-web:war:3.0.2 [WARNING] 'version' contains an expression but should be a constant. @ cy.nad.cyg:pay:${myproject.version}, D:\workspace\idea\pay\pom.xml, line 7, column 14
这是因为Maven3 不允许出现version为非常量值的情况,我们就需要第三方插件来帮我们自动完成升级版本的工作。
参见下文:
http://mojo.codehaus.org/versions-maven-plugin/examples/update-child-modules.html
这个插件等于只需要我们在parent pom中变更一下版本号,然后执行
mvn -N versions:update-child-modules这个命令,就会将所有依赖的地方全部变成新的版本号,从而帮我们完成该问题。
相关文章推荐
- Maven3 package时报 'version' contains an expression but should be a constant
- 'version' contains an expression but should be a constant
- The type of the expression must be an array type but it resolved to Point
- mm_The type of the expression must be an array type but it resolved to List
- The package needs to be reinstalled, but I can't find an archive for it.
- Variable used in lambda expression should be final or effectively final
- JLink Warning: T-bit of XPSR is 0 but should be 1. Changed to 1.
- 删除子窗体中的控件中的某些属性时出现"Selection contains a component introduced in an ancestor form which cannot be deleted."错误的解决方法
- python3爬虫问题 POST data should be bytes or an iterable of bytes
- Android问题-selection contains a component,button7,introduced in an ancestor and cannot be deleted.
- 删除子窗体中的控件中的某些属性时出现"Selection contains a component introduced in an ancestor form which cannot be deleted."错误的解决方法
- PaodingAnalysis 提示 "dic home should not be a file, but a directory"
- Keil5 IROM1 IRAM1 设置及错误JLink Warning: T-bit of XPSR is 0 but should be 1. Changed to 1.
- 50 Android Studio Tips, Tricks & Resources you should be familiar with, as an Android Developer
- 庖丁解牛 dic home should not be a file, but a directory!
- PLS-00363: expression 'v_s' cannot be used as an assignment target
- Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?an
- dic home should not be a file, but a directory!
- Layout state should be one of 100 but it is 10
- The package NAME needs to be reinstalled, but I can’t find an archive for it