一 发现问题
在pom.xml中添加依赖时语法如下
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
[color=red] [b]<version>1.2.6</version>[/b][/color]
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
[color=red][b]<version>1.2.6</version>[/b][/color]
</dependency>
以上内容没错,但有这样一个问题,在spring的依赖中,我们需要引用一系列版本的spring,如版本1.2.6。每次都写不利于维护。
二 解决办法
在pom.xml定义properties标签
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>1.2.6</spring.version>
<developer.organization><![CDATA[xy公司]]></developer.organization>
</properties>
以上内容就改成了
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
[b][color=red]<version>${spring.version}</version>[/color][/b]
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
确实很清晰明了。
在pom.xml中添加依赖时语法如下
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
[color=red] [b]<version>1.2.6</version>[/b][/color]
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
[color=red][b]<version>1.2.6</version>[/b][/color]
</dependency>
以上内容没错,但有这样一个问题,在spring的依赖中,我们需要引用一系列版本的spring,如版本1.2.6。每次都写不利于维护。
二 解决办法
在pom.xml定义properties标签
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>1.2.6</spring.version>
<developer.organization><![CDATA[xy公司]]></developer.organization>
</properties>
以上内容就改成了
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
[b][color=red]<version>${spring.version}</version>[/color][/b]
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
确实很清晰明了。