Java Spring Boot項目結(jié)構(gòu)

springboot項目結(jié)構(gòu)圖.png

1、 代碼層的結(jié)構(gòu)

根目錄:cn.bcsoft.interfacedemo

1.1、啟動類(InterfacedemoApplication.java)

/**
 *  @SpringBootApplication 來標(biāo)注一個主程序類,說明這是一個Spring Boot應(yīng)用
 */
@SpringBootApplication

public class InterfacedemoApplication {
    public static void main(String[] args) {
        // Spring應(yīng)用啟動起來
        SpringApplication.run(InterfacedemoApplication.class,args);
    }
}

項目啟動時,其當(dāng)前層及子目錄中所有controller會被編譯,可以通過直接運(yùn)行該類來 啟動 Spring Boot應(yīng)用。

@SpringBootApplication注解.png
  • @SpringBootConfiguration
    Spring Boot的配置類:標(biāo)注在某個類上,表示這是一個Spring Boot的配置類;
  • @Configuration
    配置類上來標(biāo)注這個注解;
    配置類 - 配置文件;配置類也是容器中的一個組件;@Component
  • @EnableAutoConfiguration
    開啟自動配置功能;以前我們需要配置的東西,Spring Boot幫我們自動配置;
  • @EnableAutoConfiguration
    告訴SpringBoot開啟自動配置功能;這樣自動配置才能生效;

1.2、前端控制層(controller)

1.3、數(shù)據(jù)接口訪問層(dao)

  • jpa項目: cn.bcsoft.interfacedemo.repository
  • mybatis項目: cn.bcsoft.interfacedemo.mapper

1.4、實體類(entity)

  • A:jpa項目:
    cn.bcsoft.interfacedemo.domain
  • B:mybatis項目:
    cn.bcsoft.interfacedemo.pojo
    cn.bcsoft.interfacedemo.entity

1.5、數(shù)據(jù)接口訪問層(service)

數(shù)據(jù)服務(wù)的實現(xiàn)接口(serviceImpl):
cn.bcsoft.interfacedemo.service.impl

1.6、其他

  • 工具類庫(utils)
  • 常量接口類(constant)
  • 配置類(config)
  • 視圖包裝對象(vo)
    視圖包裝對象(View Object)用于封裝客戶端請求的數(shù)據(jù),防止部分?jǐn)?shù)據(jù)泄露(如:管理員ID),保證數(shù)據(jù)安全,不破壞 原有的實體類結(jié)構(gòu)
  • 數(shù)據(jù)傳輸對象(dto)
    數(shù)據(jù)傳輸對象(Data Transfer Object)用于封裝多個實體類(domain)之間的關(guān)系,不破壞原有的實體類結(jié)構(gòu)

2、 資源文件的結(jié)構(gòu)

根目錄:src/main/resources

2.1、項目配置文件

  • application.yml
server:
  port: 9069 #端口號
spring:
  #數(shù)據(jù)源
  datasource: 
    name: oracle
    driver-class-name: oracle.jdbc.OracleDriver
    url: jdbc:oracle:thin:@127.0.0.1:orcl
    username: test
    password: test
    hikari:
      minimum-idle: 5
      maximum-pool-size: 15
      connection-test-query: select 1 from dual
      max-lifetime: 1800000
      connection-timeout: 30000
      pool-name: DatebookHikariCP
 
  mvc:
    view: #springmvc視圖解析器
      prefix: /WEB-INF/jsp/ #前綴
      suffix: .jsp #后綴
 
mybatis:
  mapper-locations: classpath:mapper/*/*.xml
  • application.properties
    用于存放程序的各種依賴模塊的配置信息,比如 服務(wù)端口,數(shù)據(jù)庫連接配置等。

2.2、靜態(tài)資源目錄:(static)

用于存放html、css、js、圖片等資源

2.3、視圖模板目錄(templates)

用于存放jsp、thymeleaf等模板文件

2.4、mybatis項目

  • 映射文件(mapper)
  • 配置文件
    mapper/config
    resources/spring-mybatis.xml
    springboot 啟動會掃描以下位置的application.properties或者application.yml文件作為Spring boot的默認(rèn)配置文件。

2.5、國際化(i18n)

3、 單元測試目錄

根目錄:src/test
單元測試目錄,生成的 ApplicationTests 通過 JUnit4實現(xiàn),可以直接用運(yùn)行 Spring Boot應(yīng)用的測試。

4、項目配置

–file:./config/
–file:./
–classpath:/config/
–classpath:/
優(yōu)先級由高到底,高優(yōu)先級的配置會覆蓋低優(yōu)先級的配置;
SpringBoot會從這四個位置全部加載主配置文件;互補(bǔ)配置;

4.1、Pom 包介紹

pom.xml 文件主要描述了項目包的依賴和項目構(gòu)建時的配置,在默認(rèn)的 pom.xml 包中分為四大塊。

4.1.1 項目的描述信息

<groupId>com.neo</groupId>//項目的包路徑
<artifactId>hello</artifactId>//項目名稱
<version>2.0.5.RELEASE</version>//項目版本號
<packaging>jar</packaging>//一般有兩個值:jar、war,表示使用 Maven 打包時構(gòu)建成 Jar 包還是 War 包

<name>hello</name>//項目名稱
<description>Demo project for Spring Boot</description>//項目描述

4.1.2 為項目的依賴配置信息

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.5.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>//web模塊正常運(yùn)行所依賴的組件
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
  </dependency>
</dependencies>
  • parent,標(biāo)簽內(nèi)配置 Spring Boot 父級版本 spring-boot-starter-parent,Maven 支持項目的父子結(jié)構(gòu),引入父級后會默認(rèn)繼承父級的配置;
  • dependencies,標(biāo)簽內(nèi)配置項目所需要的依賴包,Spring Boot 體系內(nèi)的依賴組件不需要填寫具體版本號,spring-boot-starter-parent 維護(hù)了體系內(nèi)所有依賴包的版本信息。
  • <scope>test</scope>,表示依賴的組件僅僅參與測試相關(guān)的工作,包括測試代碼的編譯和執(zhí)行,不會被打包包含進(jìn)去;
  • spring-boot-starter-test 是 Spring Boot 提供項目測試的工具包,內(nèi)置了多種測試工具,方便我們在項目中做單元測試、集成測試。

4.1.3 構(gòu)建時需要的公共變量

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>//項目構(gòu)建時所使用的編碼
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>//輸出所使用的編碼
  <java.version>1.8</java.version>//指定了項目使用的 JDK 版本
</properties>

4.1.4 構(gòu)建配置

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

使用 Maven 構(gòu)建 Spring Boot 項目必須依賴于 spring-boot-maven-plugin 組件,spring-boot-maven-plugin 能夠以 Maven 的方式為應(yīng)用提供 Spring Boot 的支持,即為 Spring Boot 應(yīng)用提供了執(zhí)行 Maven 操作的可能。spring-boot-maven-plugin 能夠?qū)?Spring Boot 應(yīng)用打包為可執(zhí)行的 jar 或 war 文件,然后以簡單的方式運(yùn)行 Spring Boot 應(yīng)用。

4.2、全局配置setting.xml 介紹

<?xml version="1.0" encoding="UTF-8"?>
<!--
 | 官方文檔: https://maven.apache.org/settings.html
 |
 | Maven 提供以下兩種 level 的配置:
 |
 |  1. User Level.      當(dāng)前用戶獨享的配置, 通常在 ${user.home}/.m2/settings.xml 目錄下。 
 |                      可在 CLI 命令行中通過以下參數(shù)設(shè)置:  -s /path/to/user/settings.xml
 |
 |  2. Global Level.    同一臺計算機(jī)上的所有 Maven 用戶共享的全局配置。 通常在${maven.home}/conf/settings.xml目錄下。
 |                      可在 CLI 命令行中通過以下參數(shù)設(shè)置:  -gs /path/to/global/settings.xml
 |
 |  備注:  User Level 優(yōu)先級 > Global Level
 |-->

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!--
     | Maven 依賴搜索順序, 當(dāng)我們執(zhí)行 Maven 命令時, Maven 開始按照以下順序查找依賴的庫: 
     | 步驟 1 - 在本地倉庫中搜索, 如果找不到, 執(zhí)行步驟 2, 如果找到了則執(zhí)行其他操作。
     | 步驟 2 - 在中央倉庫中搜索, 如果找不到, 并且有一個或多個遠(yuǎn)程倉庫已經(jīng)設(shè)置, 則執(zhí)行步驟 4, 如果找到了則下載到本地倉庫中已被將來引用。
     | 步驟 3 - 如果遠(yuǎn)程倉庫沒有被設(shè)置, Maven 將簡單的停滯處理并拋出錯誤(無法找到依賴的文件)。
     | 步驟 4 - 在一個或多個遠(yuǎn)程倉庫中搜索依賴的文件, 如果找到則下載到本地倉庫已被將來引用, 否則 Maven 將停止處理并拋出錯誤(無法找到依賴的文件)。
     |-->

    <!-- 地倉庫路徑, 默認(rèn)值: ${user.home}/.m2/repository -->
    <localRepository>${user.home}/workspace/env/maven/repository</localRepository>

    <!-- 當(dāng) maven 需要輸入值的時候, 是否交由用戶輸入, 默認(rèn)為true;false 情況下 maven 將根據(jù)使用配置信息進(jìn)行填充 -->
    <interactiveMode>true</interactiveMode>

    <!-- 是否支持聯(lián)網(wǎng)進(jìn)行 artifact 下載、 部署等操作, 默認(rèn): false -->
    <offline>false</offline>

    <!-- 
     | 搜索插件時, 如果 groupId 沒有顯式提供時, 則以此處配置的 groupId 為默認(rèn)值, 可以簡單理解為默認(rèn)導(dǎo)入這些 groupId 下的所有 artifact(需要時才下載)
     | 默認(rèn)情況下該列表包含了 org.apache.maven.plugins和org.codehaus.mojo
       | 查看插件信息: 
     |    mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin:3.5.1 -Ddetail
     |-->
    <pluginGroups>

        <!-- plugin 的 groupId -->
        <!--
        <pluginGroup>com.your.plugins</pluginGroup>
        -->

    </pluginGroups>

    <!-- 進(jìn)行遠(yuǎn)程服務(wù)器訪問時所需的授權(quán)配置信息。通過系統(tǒng)唯一的 server-id 進(jìn)行唯一關(guān)聯(lián) -->
    <servers>
        <server>
            <!-- 這是 server 的 id, 該 id 與 distributionManagement 中 repository 元素的id 相匹配 -->
            <id>server_id</id>

            <!-- 鑒權(quán)用戶名 -->
            <username>auth_username</username>

            <!-- 鑒權(quán)密碼 -->
            <password>auth_pwd</password>

            <!-- 鑒權(quán)時使用的私鑰位置。和前兩個元素類似, 私鑰位置和私鑰密碼指定了一個私鑰的路徑(默認(rèn)是/home/hudson/.ssh/id_dsa)以及如果需要的話, 一個密鑰 -->
            <privateKey>path/to/private_key</privateKey>

            <!-- 鑒權(quán)時使用的私鑰密碼, 非必要, 非必要時留空 -->
            <passphrase>some_passphrase</passphrase>

            <!-- 
             | 文件被創(chuàng)建時的權(quán)限。如果在部署的時候會創(chuàng)建一個倉庫文件或者目錄, 這時候就可以使用權(quán)限(permission)
             | 這兩個元素合法的值是一個三位數(shù)字, 其對應(yīng)了unix文件系統(tǒng)的權(quán)限, 如664, 或者775 
             |-->
            <filePermissions>664</filePermissions>

            <!-- 目錄被創(chuàng)建時的權(quán)限 -->
            <directoryPermissions>775</directoryPermissions>

            <!-- 傳輸層額外的配置項 -->
            <configuration></configuration>

        </server>
    </servers>

    <!-- 
   | 從遠(yuǎn)程倉庫才下載 artifacts 時, 用于替代指定遠(yuǎn)程倉庫的鏡像服務(wù)器配置;
   | 例如當(dāng)您無法連接上國外的倉庫是, 可以指定連接到國內(nèi)的鏡像服務(wù)器;
   | pom.xml 和 setting.xml 中配置的倉庫和鏡像優(yōu)先級關(guān)系(mirror 優(yōu)先級高于 repository): 
   |    repository(setting.xml) < repository(pom.xml) < mirror(setting.xml)
   |    例如, 如果配置了 mirrorOf = *,  則 不管項目的 pom.xml 配置了什么倉庫, 最終都會被鏡像到 鏡像倉庫
   |
   |  私服的配置推薦用profile配置而不是mirror
   |-->
    <mirrors>
        <!-- 
         | 【mirro 匹配順序】: 
         | 多個 mirror 優(yōu)先級 按照 id字母順序進(jìn)行排列(即與編寫的順序無關(guān))
         | 在第一個 mirror 找不到 artifact, 不會繼續(xù)超找下一個鏡像。
         | 只有當(dāng) mirror 無法鏈接的時候, 才會嘗試鏈接下一個鏡像, 類似容災(zāi)備份。
         |-->

        <!-- 上海交通大學(xué)反向代理 --> 
        <mirror>

            <!-- 該鏡像的唯一標(biāo)識符, id用來區(qū)分不同的 mirror 元素, 同時會套用使用 server 中 id 相同授權(quán)配置鏈接到鏡像 -->
            <id>sjtugmaven</id>

            <!-- 鏡像名稱, 無特殊作用, 可視為簡述 -->
            <name>sjtug maven proxy</name>

            <!-- 鏡像地址 -->
            <url>https://mirrors.sjtug.sjtu.edu.cn/maven-central/</url>
            <!-- 被鏡像的服務(wù)器的id, 必須與 repository 節(jié)點設(shè)置的 ID 一致。但是 This must not match the mirror id
             | mirrorOf 的配置語法: 
             | *           = 匹配所有遠(yuǎn)程倉庫。 這樣所有 pom 中定義的倉庫都不生效
             | external:*  = 匹配除 localhost、使用 file:// 協(xié)議外的所有遠(yuǎn)程倉庫
             | repo1,repo2 = 匹配倉庫 repo1 和 repo2
             | *,!repo1    = 匹配所有遠(yuǎn)程倉庫, repo1 除外
             |-->
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>

    <!-- 用來配置不同的代理, 多代理 profiles 可以應(yīng)對筆記本或移動設(shè)備的工作環(huán)境: 通過簡單的設(shè)置 profile id 就可以很容易的更換整個代理配置 -->
    <proxies>
        <!-- 代理元素包含配置代理時需要的信息 -->
        <proxy>

            <!-- 代理的唯一定義符, 用來區(qū)分不同的代理元素 -->
            <id>example_proxy</id>

            <!-- 該代理是否是激活的那個。true則激活代理。當(dāng)我們聲明了一組代理, 而某個時候只需要激活一個代理的時候, 該元素就可以派上用處 -->
            <active>false</active>

            <!-- 代理的協(xié)議 -->
            <protocol>https</protocol>

            <!-- 代理的主機(jī)名 -->
            <host>proxy.molo.com</host>

            <!-- 代理的端口 -->
            <port>443</port>

            <!-- 代理服務(wù)器認(rèn)證的登錄名 -->
            <username>proxy_user</username>

            <!-- 代理服務(wù)器認(rèn)證登錄密碼 -->
            <password>proxy_pwd</password>

            <!-- 不該被代理的主機(jī)名列表。該列表的分隔符由代理服務(wù)器指定;例子中使用了豎線分隔符, 使用逗號分隔也很常見 -->
            <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>

        </proxy>
    </proxies>

    <!--
     | 構(gòu)建方法的配置清單, maven 將根據(jù)不同環(huán)境參數(shù)來使用這些構(gòu)建配置。
     | settings.xml 中的 profile 元素是 pom.xml 中 profile 元素的裁剪版本。
     | settings.xml 負(fù)責(zé)的是整體的構(gòu)建過程, pom.xml 負(fù)責(zé)單獨的項目對象構(gòu)建過程。
     | settings.xml 只包含了id, activation, repositories, pluginRepositories 和 properties 元素。
     | 
     | 如果 settings 中的 profile 被激活, 它的值會覆蓋任何其它定義在 pom.xml 中或 profile.xml 中的相同 id 的 profile。
     |
     | 查看當(dāng)前激活的 profile:
     |   mvn help:active-profiles
     |-->
    <profiles>
        <profile>
            <!-- 該配置的唯一標(biāo)識符 -->
            <id>profile_id</id>

            <!--
             | profile 的激活條件配置;
             | 其他激活方式: 
             | 1. 通過 settings.xml 文件中的 activeProfile 元素進(jìn)行指定激活。
             | 2. 在命令行, 使用-P標(biāo)記和逗號分隔的列表來顯式的激活, 如: mvn clean package -P myProfile)。 
             |-->
            <activation>

                <!-- 是否默認(rèn)激活 -->
                <activeByDefault>false</activeByDefault>

                <!--  內(nèi)建的 java 版本檢測, 匹配規(guī)則: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html -->
                <jdk>9.9</jdk>

                <!-- 內(nèi)建操作系統(tǒng)屬性檢測, 配置規(guī)則: https://maven.apache.org/enforcer/enforcer-rules/requireOS.html -->
                <os>

                    <!-- 操作系統(tǒng) -->
                    <name>Windows XP</name>

                    <!-- 操作系統(tǒng)家族 -->
                    <family>Windows</family>

                    <!-- 操作系統(tǒng) -->
                    <arch>x86</arch>

                    <!-- 操作系統(tǒng)版本 -->
                    <version>5.1.2600</version>
                </os>

                <!--
                 | 如果Maven檢測到某一個屬性(其值可以在POM中通過${名稱}引用), 并且其擁有對應(yīng)的名稱和值, Profile就會被激活。
                 | 如果值字段是空的, 那么存在屬性名稱字段就會激活profile, 否則按區(qū)分大小寫方式匹配屬性值字段
                 |-->
                <property>

                    <!-- 屬性名 -->
                    <name>mavenVersion</name>

                    <!-- 屬性值 -->
                    <value>2.0.3</value>

                </property>
                
                <!-- 根據(jù)文件存在/不存在激活profile -->
                <file>

                    <!-- 如果指定的文件存在, 則激活profile -->
                    <exists>/path/to/active_on_exists</exists>

                    <!-- 如果指定的文件不存在, 則激活profile -->
                    <missing>/path/to/active_on_missing</missing>

                </file>
            </activation>
            <!-- 擴(kuò)展屬性設(shè)置。擴(kuò)展屬性可以在 POM 中的任何地方通過 ${擴(kuò)展屬性名} 進(jìn)行引用
             | 屬性引用方式(包括擴(kuò)展屬性, 共 5 種屬性可以引用): 
             | env.x                  : 引用 shell 環(huán)境變量, 例如, "env.PATH"指代了 $path 環(huán)境變量(在 Linux / Windows 上是 %PATH% ).
             | project.x              : 引用 pom.xml(根元素就是 project) 中 xml 元素內(nèi)容.例如 ${project.artifactId} 可以獲取 pom.xml 中設(shè)置的 <artifactId /> 元素的內(nèi)容
             | settings.x             : 引用 setting.xml(根元素就是 setting) 中 xml 元素內(nèi)容, 例如 ${settings.offline}
             | Java System Properties : 所有可通過 java.lang.System.getProperties() 訪問的屬性都能在通過 ${property_name} 訪問, 例如 ${java.home}
             | x                      : 在 <properties/> 或者 外部文件 中設(shè)置的屬性, 都可以 ${someVar} 的形式使用
             | 
             |-->
            <properties>

                <!-- 在當(dāng)前 profile 被激活時,  ${profile.property} 就可以被訪問到了 -->
                <profile.property>this.property.is.accessible.when.current.profile.actived</profile.property>

            </properties>
            <!-- 遠(yuǎn)程倉庫列表 -->
            <repositories>
                <!-- 
                 | releases vs snapshots
                 | maven 針對 releases、snapshots 有不同的處理策略, POM 就可以在每個單獨的倉庫中, 為每種類型的 artifact 采取不同的策略
                 | 例如: 
                 |     開發(fā)環(huán)境 使用 snapshots 模式實時獲取最新的快照版本進(jìn)行構(gòu)建
                 |     生成環(huán)境 使用 releases 模式獲取穩(wěn)定版本進(jìn)行構(gòu)建
                 | 參見repositories/repository/releases元素 
                 |-->

                <!--
                 | 依賴包不更新問題:                
                 | 1. Maven 在下載依賴失敗后會生成一個.lastUpdated 為后綴的文件。如果這個文件存在, 那么即使換一個有資源的倉庫后, Maven依然不會去下載新資源。
                 |    可以通過 -U 參數(shù)進(jìn)行強(qiáng)制更新、手動刪除 .lastUpdated 文件:
                 |      find . -type f -name "*.lastUpdated" -exec echo {}" found and deleted" \; -exec rm -f {} \;
                 | 2. updatePolicy 設(shè)置更新頻率不對, 導(dǎo)致沒有觸發(fā) maven 檢查本地 artifact 與遠(yuǎn)程 artifact 是否一致
                 |-->
                <repository>

                    <!-- 遠(yuǎn)程倉庫唯一標(biāo)識 -->
                    <id>maven_repository_id</id>

                    <!-- 遠(yuǎn)程倉庫名稱 -->
                    <name>maven_repository_name</name>

                    <!-- 遠(yuǎn)程倉庫URL, 按protocol://hostname/path形式 -->
                    <url>http://host/maven</url>

                    <!-- 
                    | 用于定位和排序 artifact 的倉庫布局類型-可以是 default(默認(rèn))或者 legacy(遺留)
                    | Maven 2為其倉庫提供了一個默認(rèn)的布局;然而, Maven 1.x有一種不同的布局。我們可以使用該元素指定布局是default(默認(rèn))還是legacy(遺留)
                    | -->
                    <layout>default</layout>
                    <!-- 如何處理遠(yuǎn)程倉庫里發(fā)布版本的下載 -->
                    <releases>

                        <!-- 是否允許該倉庫為 artifact 提供 發(fā)布版 / 快照版 下載功能 -->
                        <enabled>false</enabled>

                        <!-- 
                         | 每次執(zhí)行構(gòu)建命令時, Maven 會比較本地 POM 和遠(yuǎn)程 POM 的時間戳, 該元素指定比較的頻率。
                         | 有效選項是: 
                         |     always(每次構(gòu)建都檢查), daily(默認(rèn), 距上次構(gòu)建檢查時間超過一天), interval: x(距上次構(gòu)建檢查超過 x 分鐘)、 never(從不)
                         | 重要: 
                         |     設(shè)置為 daily, 如果 artifact 一天更新了幾次, 在一天之內(nèi)進(jìn)行構(gòu)建, 也不會從倉庫中重新獲取最新版本
                         |-->
                        <updatePolicy>always</updatePolicy>

                        <!-- 當(dāng) Maven 驗證 artifact 校驗文件失敗時該怎么做: ignore(忽略), fail(失?。? 或者warn(警告) -->
                        <checksumPolicy>warn</checksumPolicy>

                    </releases>

                    <!-- 如何處理遠(yuǎn)程倉庫里快照版本的下載 -->
                    <snapshots>
                        <enabled />
                        <updatePolicy />
                        <checksumPolicy />
                    </snapshots>
                </repository>
                <!-- 
                    國內(nèi)可用的 maven 倉庫地址(updated @ 2019-02-08):

                    http://maven.aliyun.com/nexus/content/groups/public
                    http://maven.wso2.org/nexus/content/groups/public/
                    http://jcenter.bintray.com/
                    http://maven.springframework.org/release/
                    http://repository.jboss.com/maven2/
                    http://uk.maven.org/maven2/
                    http://repo1.maven.org/maven2/
                    http://maven.springframework.org/milestone
                    http://maven.jeecg.org/nexus/content/repositories/
                    http://repo.maven.apache.org/maven2
                    http://repo.spring.io/release/
                    http://repo.spring.io/snapshot/
                    http://mavensync.zkoss.org/maven2/
                    https://repository.apache.org/content/groups/public/
                    https://repository.jboss.org/nexus/content/repositories/releases/   
                -->

            </repositories>

            <!-- 
             | maven 插件的遠(yuǎn)程倉庫配置。maven 插件實際上是一種特殊類型的 artifact。
             | 插件倉庫獨立于 artifact 倉庫。pluginRepositories 元素的結(jié)構(gòu)和 repositories 元素的結(jié)構(gòu)類似。
             |-->
            <!--
            <pluginRepositories>
                <pluginRepository>
                    <releases>
                        <enabled />
                        <updatePolicy />
                        <checksumPolicy />
                    </releases>
                    <snapshots>
                        <enabled />
                        <updatePolicy />
                        <checksumPolicy />
                    </snapshots>
                    <id />
                    <name />
                    <url />
                    <layout />
                </pluginRepository>
            </pluginRepositories>
            -->

        </profile>
    </profiles>
    <!--
     | 手動激活 profiles 的列表, 按照 profile 被應(yīng)用的順序定義 activeProfile
     | 任何 activeProfile, 不論環(huán)境設(shè)置如何, 其對應(yīng)的 profile 都會被激活, maven 會忽略無效(找不到)的 profile
     |-->
    <!--
    <activeProfiles>
        <activeProfile>not-exits-profile</activeProfile>
    </activeProfiles>
    -->

</settings>

以上即為 pom.xml 文件基礎(chǔ)內(nèi)容,幾乎所有的 Spring Boot 項目都會用到以上配置信息。

參考文檔

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容