springboot 项目启动无法加载到 application 文件


今天遇到一个问题,项目启动可以加载到 apollo(配置中心) 中配置的配置文件,但是在自己本地resources目录下新增了一个 application.properties 文件并在里面配置了配置文件么但是不起作用的问题。

经过验证,需要在 pom.xml 文件中配置加载文件。配置如下。


simple-callback


org.springframework.boot
spring-boot-maven-plugin

true




org.mybatis.generator
mybatis-generator-maven-plugin
1.3.2

src/main/resources/generatorConfig.xml
true
true



org.apache.maven.plugins
maven-compiler-plugin
3.1


org.apache.maven.plugins
maven-surefire-plugin
2.18.1

true



org.apache.maven.plugins
maven-clean-plugin
2.6.1





src/main/java

**/*.xml

false


src/main/resources

**/*.xml
META-INF/app.properties
**/*.properties
**/*.yml

false


上面标红的配置文件就是指定项目启动需要加载的配置文件,以上标红配置解决了  项目启动无法加载配置文件的问题