spring boot, maven 사용자 정의 프로필
2561 단어 maven
local
src/main/profile
src/main/resources
true
resources 속성 은 파일 자원 을 설정 하 는 경 로 를 지정 합 니 다.
id 는 maven 을 컴 파일 할 때 대응 하 는 값 을 지정 하고 해당 하 는 id 를 사용 할 수 있 는 profile 입 니 다.
activationByDefault 속성 은 이 프로필 을 기본 불 러 오기 프로필 로 지정 합 니 다.
컴 파일 할 때 mvn - P local 명령 을 사용 하면 id 를 local profile 로 불 러 옵 니 다.
프로필 을 설정 한 후 프로그램 을 실행 하면 target / classes 디 렉 터 리 에 application. properties 파일 이 있 습 니 다. 열 어 보 세 요. 자신의 프로필 을 위 한 것 입 니 다.
그럼 프로필 에 두 개의 경로 가 설정 되 어 있 지 않 습 니까?src / main / profile 과 src / main / resources, 왜 application. properties 만 있 습 니까?src / main / resources 의 프로필 에 설정 이 쓰 여 있 지 않 습 니 다. 그런데 이 프로필 은 왜 classpath 에 불 러 오지 않 았 습 니까?
pom. xml 의 prolees 설정 을 다음 과 같이 조정 해 보 세 요.
local
src/main/resources
src/main/profile
true
다시 실행 하 니 프로그램 이 잘못 되 었 습 니 다. 설정 을 찾 을 수 없습니다. target / classes 에 들 어가 보 니 application. properties 에는 아무것도 없습니다.
다시 말 하면 pom. xml 에서 profflee 의 경 로 는 아래 에서 위로 불 러 옵 니 다. 그러면 같은 이름 의 파일 이 있 으 면 위의 profflee 경 로 는 아래 를 덮어 씁 니 다.
두 경로 의 프로필 을 다른 이름 으로 바 꾸 면 target / classes 에 두 속성 프로필 이 있 습 니 다.
그러나 이 때 는 spring boot 메 인 클래스 에 새 속성 파일 의 주 해 를 추가 해 야 합 니 다.
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@PropertySource("classpath:app.properties")
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
큰 성 과 를 거두다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Windows에서 CodeArtifact(Maven)용 토큰을 자동으로 생성하는 방법CodeArtifact를 사용한 적이 있거나 사용할 계획이라면 매일 모든 Maven 프로젝트에서 수동으로 토큰(CODEARTIFACT_AUTH_TOKEN)을 생성해야 합니다. 이는 어려울 수 있으며 개발 속도를 늦출...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.