Java maven的 pom.xml配置文件中使用全局变量配置版本号

  • Post author:
  • Post category:java


配置全局变量控制版本号,修改起来比较快速方便,使用方式分两步:

第一步:在pom.xml文件中的<dependencies>标签前新增一个标签<properties></properties>

 <properties>
		<project.artifactId>CarCenterSys</project.artifactId>
		<springside.version>4.2.2.GA</springside.version>
		<spring.version>4.2.5.RELEASE</spring.version>
		<mybatis.version>3.2.5</mybatis.version>
		<mybatis-spring.version>1.2.2</mybatis-spring.version>
		<logback.version>1.1.1</logback.version>
		<tomcat-jdbc.version>8.0.35</tomcat-jdbc.version>
		<jackson.version>2.3.1</jackson.version>
	</properties>

<dependencies>

......

</dependencies>

第二步:使用方式为${之前定义的标签名称}

<dependencies>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>${logback.version}</version>
			<scope>runtime</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>${mybatis.version}</version>
		</dependency>

		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>${mybatis-spring.version}</version>
		</dependency>

		<!-- connection pool -->
		<dependency>
			<groupId>org.apache.tomcat</groupId>
			<artifactId>tomcat-jdbc</artifactId>
			<version>${tomcat-jdbc.version}</version>
			<scope>runtime</scope>
		</dependency>
</dependencies>

OK,是不是方便很多呢?


转载于:https://my.oschina.net/lmxy1990/blog/754359