반응형
Maven 리소스 필터링이 작동하지 않음-스프링 부트 종속성으로 인해
이 질문에 이미 답변이 있습니다.
maven 프로젝트에서 maven 리소스 필터링을 사용하여 일부 토큰을 교체하려고 시도했지만 작동하지 않습니다. 나는 작동하지만이 단일 프로젝트에서 작동하지 않는 다른 프로젝트가 있는데 무엇이 잘못되었는지 확실하지 않습니다.
특성 파일은 /src/main/resources/my.properties 위치에 있습니다.
아래와 같이 다른 maven 명령을 시도했지만 작동하지 않습니다.
mvn clean install
mvn clean install resources:resources
my.properties
### Spring boot properties
jdbc.url=${jdbc.url}
ldap.domain=${ldap_domain}
ldap.url=${ldap_url}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jai</groupId>
<artifactId>client</artifactId>
<version>0.0.6-SNAPSHOT</version>
<name>client</name>
<description>client web application</description>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
</dependencies>
<build>
<finalName>client</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>exec-bower-install</id>
<phase>generate-sources</phase>
<configuration>
<executable>bower</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!-- localhost environment -->
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<ldap_domain>mydomain.local</ldap_domain>
<ldap_url>ldap://server:389</ldap_url>
<jdbc.url>testttttttttttttttttttttt</jdbc.url>
</properties>
</profile>
</profiles>
</project>
최신 정보:-
이 문제는 스프링 부트 종속성으로 인해 발생한다는 것을 알았습니다. <parent>
섹션 및 기타 스프링 부트 종속성에 대해 주석을 달면 제대로 작동하고 토큰을 대체 할 수 있습니다. 그러나 여전히 스프링 부츠를 유지하여 이것을 고치는 방법을 모르겠습니다.
At last found the answer from the link in my comments. As this is a spring boot application ...special case... the notations should be
@xxxxx@ instead of ${xxxxx}
So my property file would be as below
### Spring boot properties
jdbc.url=@jdbc.url@
ldap.domain=@ldap_domain@
ldap.url=@ldap_url@
반응형
'code' 카테고리의 다른 글
JSON 결과를 날짜로 변환 (0) | 2020.10.09 |
---|---|
Scala 목록을 튜플로 변환 하시겠습니까? (0) | 2020.10.09 |
기능과 레이블의 차이점은 무엇입니까? (0) | 2020.10.09 |
람다 함수 및 매개 변수의 범위? (0) | 2020.10.09 |
미국 우편 번호를 시간대에 매핑 (0) | 2020.10.08 |