내가 spring.config.location을 지정할 때 봄 부팅 2.x를하지 스캔 application.properties을한다

TOAN 다오 :

난 그냥 봄 부팅 2.0.4 놀아 나는이 오늘 알 그래서. 내가 뭔가를 놓친 여부를 확인하지 않습니다. 나를 확인하는 데 도움이 바랍니다.

봄 응용 프로그램

@SpringBootApplication
@EnableScheduling
public class Application extends SpringBootServletInitializer {

application.properties (SRC / 메인 / 자원에 위치)

server.port=8088

인 IntelliJ를 사용하여 프로젝트를 시작합니다

2018-08-17 12:11:05 INFO  o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8088 (http) with context path ''

자바 명령 줄을 사용하여 프로젝트를 시작합니다 :

java -jar sample.jar --spring.config.location=D:\config\ --spring.profiles.active=dev

응용 프로그램이 구성된 포트를 사용하지 않는

2018-08-17 11:25:25 INFO  o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path ''

(:가 다른 구성 파일이 중복되지 않도록, 더 다른 어디에만 applications.properties이 구성 주) 봄 부팅 2.0처럼의 모습은 기본 속성 파일을 무시

davidxxx :

당신은 지정 spring.config.location동네 짱 항아리를 시작하고 명시된 봄 부팅 2에서,이 인수를 지정하면 봄에 사용되는 기본 위치를 대체 문서에 .

사용자 지정 설정 위치를 사용하여 구성 할 때 spring.config.location, 그들은 기본 위치를 대체합니다. 예를 들어,이 spring.config.location값으로 설정되어 classpath:/custom-config/, file:./custom-config/검색 순서는 다음이된다 :

  1. file:./custom-config/

  2. classpath:custom-config/

난 당신이 명시 적으로 추가 할 필요가 있다고 생각 그래서 application.properties에서 spring.config.location:

--spring.config.location=D:\config\,classpath:\application.properties

또는 대체 사용으로 spring.config.additional-location같은 --spring.config.additional-location=D:\config\대신 spring.config.location이 추가보다는 위치를 대체 할 문서에 의해 명시된 바와 같이 :

사용자 지정 설정 위치가 spring.config.additional-위치를 사용하여 구성하는 경우 또는, 그들은 기본 위치에 추가로 사용된다.

추천

출처http://43.154.161.224:23101/article/api/json?id=197660&siteId=1