父pom文件:

<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

 

Maven3 package时报 'version' contains an expression but should be a constant的更多相关文章

  1. maven2 up to maven3的'version' contains an expression but should be a constant

    在Maven2时,为了保障版本一致,一般之前我们的做法时: Parent Pom中 <project xmlns="http://maven.apache.org/POM/4.0.0& ...

  2. 'version' contains an expression but should be a constant

    [WARNING] Some problems were encountered while building the effective model for com.app:cache:jar:4. ...

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

    <modelVersion>4.0.0</modelVersion> <groupId>cy.nad.cyg</groupId> <artifac ...

  4. Windows Maven package时报错问题的解决

    google了一把,看到别人的说法是Stack size 不够大. Stack Space用来做方法的递归调用时压入Stack Frame.所以当递归调用太深的时候,就有可能耗尽Stack Space ...

  5. Theos 工程make package时报错

    错误: /Applications/Xcode.app/Contents/Developer/usr/bin/make package requires you to have a layout/ d ...

  6. eclipse点击包(package)时报错,安装hibernate后点击包报错org/eclipse/jpt/common/utility/exception/ExceptionHandler

    错误描述: 当我们点击包名时,出现如下错误提示.An error has occurred. See error log for more details.org/eclipse/jpt/common ...

  7. pycharm安装package时报错

    在pycharm pip 包时,提示报错:module 'pip' has no attribute 'main' 原因:由于我的是pip 18.1 版本里没有main() 解决方法: 如不降级 pi ...

  8. Maven进行install的时候报错,COMPILATION ERROR : Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.13:test (default-test) on project cmu: There are test failures.

    maven进行install的时候,test类里面报错: COMPILATION ERROR : [INFO] -------------------------------------------- ...

  9. 封装smarty类

    <?php/** * Project:     Smarty: the PHP compiling template engine * File:        Smarty.class.php ...

随机推荐

  1. rancher2.x添加node的坑。

    启动rancher server后,添加一台新节点为k8s的节点.设置如下 ps:worker:k8s的agent端 control:k8s的第二个master etcd:第二个etcd 坑1:节点上 ...

  2. python-思路整理-虚拟环境

    虚拟环境: 如需多个版本的django或其他框架开发代码时,就可以用虚拟环境 pip3 install virtualenv # 创建虚拟环境 virtualenv virtualenv env1 # ...

  3. leetcode-algorithms-18 4Sum

    leetcode-algorithms-18 4Sum Given an array nums of n integers and an integer target, are there eleme ...

  4. 查看某一职责下对应的菜单&功能&请求(转)

    原文地址:查看某一职责下对应的菜单&功能&请求 查看菜单&功能 SELECT res.RESPONSIBILITY_NAME 职责名称, menu.MENU_NAME 菜单编码 ...

  5. SpringBoot系列之jar包转war包

    1.修改pom,将打包方式改为war包 2.dependencides中配置外部tomcat <!--因配置外部TOMCAT 而配置--> <dependency> <g ...

  6. python中eval()和json.dumps的使用

    在python中通过requests.get(url)获取json数据,此时可能需要eval进行解析. # -*- coding: utf-8 -*- import requests r = requ ...

  7. [LeetCode] 100. Same Tree ☆(两个二叉树是否相同)

    描述 解析 根与根比较,左右子树互相递归比较即可. 代码 /** * Definition for a binary tree node. * public class TreeNode { * in ...

  8. Python学习之路【第三篇】--集合

    语法结构: set1.issubset(set2)判断集合set1是否为set2的子集,返回布尔值. ? 1 2 3 4 5 6 s1 = {'Java', 'PHP', 'Python', 'C++ ...

  9. CentOS下安装Hbase

    1.安装JDK.https://www.cnblogs.com/zhi-leaf/p/10315125.html 2.下载Hbase.下载地址:https://hbase.apache.org/dow ...

  10. centos6.5 安装PHP7.0支持nginx

    1.安装PHP所需要的扩展           yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel ...