속성 파일의 값에 따라 context.xml 및 web.xml 파일의 내용을 업데이트하고 싶습니다. 내 웹 응용 프로그램에서 사용할 수있는 데이터베이스 연결을 설정하고 싶습니다. 이 콘텐츠를 역동적으로 추가 할 수 있습니까? 나는 현재 어떤 업데이트 내가Maven Plugin을 사용하여 파일 내용을 업데이트 할 수 있습니까?
<resource-ref>
<description>Env1 Database Connection</description>
<res-ref-name>jdbc/Env1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Env2 Database Connection</description>
<res-ref-name>jdbc/Env2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Env3 Database Connection</description>
<res-ref-name>jdbc/Env3</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Env4 Database Connection</description>
<res-ref-name>jdbc/Env4</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
다음 한 내 web.xml 파일에서 내 POM
<build>
<finalName>ROOT</finalName>
<filters>
<filter>src/main/resources/environmentProperties/env1.properties</filter>
<filter>src/main/resources/environmentProperties/env2.properties</filter>
<filter>src/main/resources/environmentProperties/env3.properties</filter>
<filter>src/main/resources/environmentProperties/env4.properties</filter>
</filters>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin-version}</version>
<configuration>
<webResources>
<resource>
<directory>${basedir}\src\main\resources\META-INF</directory>
<filtering>true</filtering>
<targetPath>META-INF</targetPath>
<includes>
<include>**\context.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
에 다음 빌드 섹션을 사용하여 진행 한
는 정말 수하는 것을 선호 environmentProperties 폴더에 필요한만큼 많은 특성 파일을 가지고 web.xml (및 context.xml) 파일을 갱신하여 각 환경에 적절한 항목을 추가하십시오. 이것이 가능한가.
아파치 벨로 시티는 루핑 구조를 보았지만,이를 활용할 수있는 메이븐 플러그인이 있는지 모르겠습니다.
덕분에, 폴
다시 연락해 주셔서 감사합니다. 현재 내가 가지고있는 접근법은 필터 섹션에 항목을 추가하여 특성 파일에서 값을 읽을 수 있도록 허용합니다. 하지만 내가 선호하는 것은 폴더 (src/main/resources/environmentProperties)를 지정하고 Maven을 사용하고 모든 파일을 읽으므로 다른 파일이 추가되면 POM을 수정할 필요가 없습니다. 또한 web.xml 및 context.xml 내에서 등록 정보 파일의 수에 따라 정확한 수의 항목을 작성하기로 결정했습니다. 여기에는 템플릿을 지정하는 루핑이 필요합니다. – ceepan
StringTemplate의 웹 사이트를 살펴보십시오. 템플릿 엔진이며 원하는대로 할 수 있습니다. http://www.stringtemplate.org/ - 또한 속성 플러그인이 와일드 카드를 사용할 수 있다고 생각하지만 여러 파일을 반드시 가져옵니다. – mikeb