When I use:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
on the console I get the following error message:
'dependenci开发者_如何学运维es.dependency.version' for org.springframework:spring-context:jar must be a valid version but is '${spring.version}'. @ line 40, column 19
Do I have to do a manually configuration of Maven? I've seen this kind of dependency but there is no explanation how to do it properly.
${spring.version}
is a placeholder, you need to configure its actual value in <properties>
block:
<properties>
<spring.version>3.0.5.RELEASE</spring.version>
</properties>
I don't really agree with the first answer.
Using ${spring.version}
is a convenient way to config version.
In xml file, you need to set property like follow:
<properties>
<spring.version>4.3.3.RELEASE</spring.version>
</properties>
Then it will work.
<properties>
<spring.version>4.3.2.RELEASE</spring.version>
<junit.version>4.12</junit.version>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
if you want to use ${spring.version} then first define its version in properties tag and it is good practice to use to define the version in properties tag because if we change the version then we don't need to do changes in the entire file just do change in properties tag.
There is a simple answer for that.
Add spring.version to properties section in pom.xml
.
<properties>
<spring.version>4.0.2.RELEASE</spring.version>
</properties>
精彩评论