문제

As you see from the title, I want to ask that the case of in Maven 3 there is no support for $version in pom.xml anymore. Do we have to really write a constant every time in each project in every pom.xml and related configuration files again and again? How can we avoid doing this? How can we use a versioning method like $version?

도움이 되었습니까?

해결책

The expression ${version} is deprecated, you should use ${project.version} instead, but both are still supported and you certainly don't need a custom property.

The following just works fine for me with Maven 3:

<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>services</artifactId>
  <version>${project.version}</version>
  <type>ejb</type>
</dependency>

And also have a look at my previous answer to Warning on using project.parent.version as the version of a module in Maven 3, the way you're using version (based on what I saw in the comments in another answer) doesn't make much sense IMHO and Maven 3 actually kindly suggests to follow a best practice. Just inherit the version.

다른 팁

Using a macro inside the top <version/> element and the version in the <parent/> element never worked in maven 2. It appeared to work, but caused nothing but confusion downstream. If that's not what you are talking about, please clarify your question.

The error below shows the deprecation of $(artifactId} and ${version}

[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead. [WARNING] The expression ${version} is deprecated. Please use ${project.version} instead. [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten t he stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support buildin g such malformed projects.

The warning message spells it out. Replace ${artifactId} with ${project.artifactId}, and ${version} with ${project.version}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top