'version' contains an expression but should be a constant. @ line 13, column 11问题的解决

 <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>
'version' contains an expression but should be a constant. @ line 13, column 11问题的解决

在子module中

'version' contains an expression but should be a constant. @ line 13, column 11问题的解决
<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>
'version' contains an expression but should be a constant. @ line 13, column 11问题的解决

但是升级到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这个命令,就会将所有依赖的地方全部变成新的版本号,从而帮我们完成该问题。

上一篇:网络流强化-POJ2516


下一篇:判断是否微信浏览器,是的话,加入自己想加的功能