我有一个包含两个模块(搜索和用户管理)的存储库.我希望两个模块都有自己的application.properties
.
├───pom.xml
├───search
│ ├───src
│ │ ├───main
│ │ │ ├───java
│ │ │ │ └───com
│ │ │ │ └───example
│ │ │ │ └───projectname
│ │ │ │ └───search
│ │ │ │ ├───controller
│ │ │ │ ├───model
│ │ │ │ ├───query
│ │ │ │ └───Main.class
│ │ │ └───resources
│ │ └───test
│ │ └───src
│ ├───pom.xml
│ └───target
├───target
└───usermanagement
├───src
│ └───com
│ └───example
│ └───projectname
│ └───usermanagement
├───test
│ └───src
└───pom.xml
resources
搜索目录有一个应用程序.包含以下内容的属性:
spring.profiles.active=dev
未使用此选项.我必须手动更新我的运行配置文件,并用应用程序的绝对路径通过spring.config.additional-location
.属性.
父母的pom
<dependencyManagement>
<dependencies>
<!-- Springboot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<defaultGoal>clean test install</defaultGoal>
</build>
<modules>
<module>search</module>
<module>usermanagement</module>
</modules>
搜索子对象的pom
<dependencies>
<!-- Springboot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Build jar with dependencies -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>main.java.com.example.projectname.search.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
我已经try 在parent和@PropertyScan中添加src/main/resources
.