【发布时间】:2014-08-23 13:27:36
【问题描述】:
我们有一个父项目,下面有多个子项目。他们中的一些人正在制造一场战争,而另一些人正在制造一个罐子。
在父项目中,有一个 dev.properties 文件。它在目录中
/src/main/resources/config/environments/dev.properties
这个文件被多个子项目正确使用,没有问题。
导致错误的项目在pom.xml中对jetty有如下配置
<profiles>
<profile>
<id>jetty</id>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.16</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopPort>8005</stopPort>
<stopKey>STOP</stopKey>
<contextPath>/</contextPath>
<useTestClasspath>true</useTestClasspath>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
这个项目引用我们的管理项目,如下所示:
<dependency>
<groupId>sample.project</groupId>
<artifactId>sample-project-admin-service</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
在示例项目和文件 sample-project-admin-service-context.xml 中有这样的配置:
<bean id="cacheMan"
class="org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean"
p:configurationPropertiesFileLocation="/WEB-INF/classes/config/environments/${SERVER_ENV}.properties" />
这应该读取属性文件并初始化 cacheMan。 sample-project-admin-service-context.xml 位于路径中:
/sample-project-admin-service/src/main/resources/META-INF/spring/flash-air-admin-service-context.xml
当我们制作一个war文件并将其部署到tomcat时。应用程序正确部署,没有任何问题。但是当我尝试用码头加载它时,我收到以下错误:
设置 bean 时无法解析对 bean 'cacheManager' 的引用 属性“缓存管理器”;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建在类路径资源中定义的名称为“cacheManager”的bean [META-INF/spring/sample-project-admin-service-context.xml]:调用 初始化方法失败;嵌套异常是 java.io.FileNotFoundException: 无法打开 ServletContext 资源 [/WEB-INF/classes/config/environments/dev.properties]:
Jetty maven 使用命令运行:
mvn install -Pjetty
任何帮助将不胜感激。
提前致谢
【问题讨论】:
标签: java spring maven spring-mvc maven-jetty-plugin