首页 > 编程语言 > 详细

不使用spring-boot-starter-parent进行依赖的版本管理

时间:2019-12-08 17:36:50      阅读:305      评论:0      收藏:0      [点我收藏+]

spring-boot-starter-parent 提供了Dependency Management 进行项目依赖的版本管理。

但是,当需要将其他项目作为parent 的时候,同时又希望对项目依赖版本进行统一的管理时,可以使用 dependencyManagement 来实现。

如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!-- <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.10.RELEASE</version>
        <relativePath/> lookup parent from repository
    </parent> -->
    <groupId>com.study</groupId>
    <artifactId>SpringBootTest-1</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>RequestBodyTest</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    
    <dependencyManagement>
      <dependencies>
       <dependency>
       <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>1.5.10.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
       </dependency>
      </dependencies>
    </dependencyManagement>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootTest1Application {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootTest1Application.class, args);
    }

}
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String sayHi() {
    return "Hello World";
    }
}

 

不使用spring-boot-starter-parent进行依赖的版本管理

原文:https://www.cnblogs.com/luffystory/p/12006364.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!