maven项目中的pom.xml文件

来源:互联网 发布:淘宝外卖优惠券怎么领 编辑:程序博客网 时间:2024/06/06 02:13

在使用maven开发时,在pom.xml文件中有这样两个标签<dependencyManagement><pluginManagement>对引入的依赖包和插件进行管理

<!-- 集中定义依赖版本号 -->    <properties>        <junit.version>4.10</junit.version>        <spring.version>4.1.3.RELEASE</spring.version>    </properties><dependencyManagement>        <dependencies>            <!-- 单元测试 -->            <dependency>                <groupId>junit</groupId>                <artifactId>junit</artifactId>                <version>${junit.version}</version>                <scope>test</scope>            </dependency>            <!-- Spring -->            <dependency>                <groupId>org.springframework</groupId>                <artifactId>spring-context</artifactId>                <version>${spring.version}</version>            </dependency>            <dependency>                <groupId>org.springframework</groupId>                <artifactId>spring-beans</artifactId>                <version>${spring.version}</version>            </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-aspects</artifactId>                <version>${spring.version}</version>            </dependency>    </dependencyManagement>    <build>        <finalName>${project.artifactId}</finalName>        <pluginManagement>            <plugins>                <!-- 配置Tomcat插件 -->                <plugin>                    <groupId>org.apache.tomcat.maven</groupId>                    <artifactId>tomcat7-maven-plugin</artifactId>                    <version>2.2</version>                </plugin>            </plugins>        </pluginManagement>    </build>

由父工程统一管理版本,子工程可以选择引入并省略版本号
如果子工程想使用别的版本的jar,可以直接在子工程指定版本号

原创粉丝点击