http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Pluginのように、jetty-maven-pluginを使用してWebアプリを起動しようとしています。しかし、環境構成ファイルを外部化したいと思います。これが私のプロジェクトの階層です。
myapp-webapp
- src
- - test
- - - ressources
- - - java
- - main
- - - ressources
- - - java
- - - webapp
- - - - WEB-INF
- - - - META-INF
- - - - templates
- - - - ressources
- - - - index.xhtml
+ target (I don't detail it)
- configuration
- - local
- - - databaseLocal.properties
- - - ... others config files
- - dev
- - test
- - prod
そして、これが私のpomファイルです:
<profiles>
<profile>
<id>myapp-work</id>
<activation>
<property>
<name>!env</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
<extraClasspath>configuration/local/</extraClasspath>
</webApp>
<scanTargetPatterns>
<scanTargetPattern>
<directory>configuration/local/</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</scanTargetPattern>
</scanTargetPatterns>
</configuration>
<dependencies>
<dependency>
...
</dependencies>
</plugin>
...
<plugins>
そして、私はこのエラーに直面しています2012-07-04 10:33:26.460:WARN::コンテキストの起動に失敗しましたJettyWebAppContext@ 29b829b8 @ 29b829b8 /、file:/ C:/ DEV / RTCworkspace / myapp / myapp-webapp / src / main / webapp /、file:/ C:/ DEV / RTCworkspace / myapp / myapp-webapp / src / main / webapp / org.springframework.beans.factory.BeanInitializationException:プロパティを読み込めませんでした。ネストされた例外はjava.io.FileNotFoundExceptionです:クラスパスリソース[databaseLocal.properties]が存在しないため、開くことができません
多くの情報を見つけましたが、何も機能しません: -http : //wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin-Jetty + Spring+Tilesデプロイメントで構成ファイルを見つけることができません-maven - jettyプラグインが正しいパスを使用していません
私も試してみます:$ {basedir} / $ {externalConfiguration.directory}
これがスタートアップログの抜粋です(私のウェブアプリ名はcctです、今まで置き換えました):
[INFO] webAppSourceDirectory C:\DEV\RTCworkspace\cct\cct-webapp\src\main\webapp does not exist. Defaulting to C:\DEV\RTCworkspace\cct\cct-webapp\src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\DEV\RTCworkspace\cct\cct-webapp\src\main\webapp\WEB-INF\classes
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\database.properties
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\databaseLocal.properties
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\efrit-security.properties
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\efrit.properties
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\efrit_logback.xml
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\ldap.properties
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\logback.properties
[INFO] Adding extra scan target from pattern: C:\DEV\RTCworkspace\cct\cct-webapp\configuration\local\logback.xml
[INFO] Context path = /
[INFO] Tmp directory = C:\DEV\RTCworkspace\cct\cct-webapp\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:/C:/DEV/RTCworkspace/cct/cct-webapp/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = C:\DEV\RTCworkspace\cct\cct-webapp\src\main\webapp
[INFO] Starting jetty 7.1.6.v20100715 ...2012-07-04 11:16:56.349:INFO::jetty-7.1.6.v20100715
それで彼は私の設定ファイルを見たがそれを読むことができないと言った。