1. 程式人生 > 其它 >spring boot如何講jar包抽離到最外層pom檔案中

spring boot如何講jar包抽離到最外層pom檔案中

技術標籤:spring bootjavaspring boot

  1. 首先將所有
    開始於
    <dependencies>
    結束於
    </dependencies>中的檔案放到最外層的專案中,裡面的方法就不需要寫version了
  2. 需要在2中的pom.xml檔案中新增一層
  3. <dependencyManagement>
    <dependencies>...</dependencies>
    </dependencyManagement>
  4. 可以將所有版本號資訊就行抽離
  5.     <properties>
            <project.build.soureEncoding>UTF-8</project.build.soureEncoding>
            <project.compile.soureEncoding>UTF-8</project.compile.soureEncoding>
            <sharedingsphere.version>4.1.0</sharedingsphere.version>
            <springboot.versinon>2.2.5.RELEASE</springboot.versinon>
        </properties>
    
    
     <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-jdbc</artifactId>
                    <version>${springboot.versinon}</version>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                    <version>${springboot.versinon}</version>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-test</artifactId>
                    <version>${springboot.versinon}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>5.1.8</version>
                </dependency>
    
                <dependency>
                    <groupId>org.apache.shardingsphere</groupId>
                    <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
                    <version>${sharedingsphere.version}</version>
    
                </dependency>
            </dependencies>
        </dependencyManagement>

    version中版本資訊為上面properties中配置的資訊,起到方便管理的作用