springboot載入子模組配置檔案

2021-09-26 03:30:38 字數 1349 閱讀 4320

在springboot專案搭建中,使用模組化構建的話,難免碰到要讀取其他模組中的配置檔案的情況。此時,springboot預設情況下只會讀取啟動類模組的配置檔案。大概情況如圖所示:

我的主配置類:

server.port=8080
我的其他模組配置類:

server.port=8090

spring.datasource.driver-class-name=com.mysql.jdbc.driver

spring.datasource.url=jdbc:mysql://localhost:3306/test?useunicode=true&characterencoding=utf-8

spring.datasource.password=root

spring.datasource.username=root

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.improvednamingstrategy

spring.jpa.properties.hibernate.hbm2ddl.auto=update

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.mysql5innodbdialect

spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true

spring.jpa.show-sql= true

spring.jpa.database = mysql

要想所有配置檔案都載入的話,可以在啟動類上新增@propertysource標籤,在期中配置value陣列即可

package com.example.demo;

import org.springframework.boot.web.servlet.support.springbootservletinitializer;

import org.springframework.context.annotation.propertysource;

public static void main(string args)

}

springboot正常啟動,啟動埠為8080

親測可用。

git submodule 子模組使用

當我們的git專案需要引入第三方專案 另外乙個git專案 時,可以用submodule。git submodule add third party hiredis third party hiredis 是自定義路徑 hiredis必須不存在。新增成功之後可以看到 third party hired...

Git submodule Git子模組簡介

建立倉庫 1.1 建立主倉庫 1.2 建立子倉庫 提交內容 2.1 提交到主工程的倉庫 2.2 提交到子模組的倉庫 轉殖帶子模組的倉庫到本地 更新子倉庫 總結參考文件 軟體開發中有乙個dry don t repeat yourself 原則,或者說die duplication is evil 原則...

Git工具 子模組

在專案上工作時,如果需要在其中引用另外乙個專案 第三方庫或者其他 可以通過子模組來處理這個問題。子模組允許將乙個git倉庫作為另外乙個git倉庫的子目錄.拉取 git submodule add git web path filename 會生成乙個.gitmodules配置檔案,這個檔案記錄了子專...