我正在尝试在JBoss EAP-6.4上运行我的应用程序,但是我收到以下错误:
17:29:27,353 WARN [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 62) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.xxx.yyy.appname.Config]; nested exception is java.io.FileNotFoundException: class path resource [git.properties] cannot be opened because it does not exist
17:29:27,369 ERROR [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 62) Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.xxx.yyy.appname.Config]; nested exception is java.io.FileNotFoundException: class path resource [git.properties] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181) [spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
这很奇怪,因为应用程序在WebSphere 8.5.5上没有问题,并且从配置文件中读取参数没有任何问题。
文件git.properties
位于项目中的src/main/webapp
目录下。
这是配置类。
@Configuration
@ImportResource({"classpath*:META-INF/spring/applicationContext.xml"})
@PropertySource("classpath:git.properties")
@ComponentScan("com.myapplication.controller")
@EnableWebMvc
@EnableSpringDataWebSupport
public class Config extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
我已阅读the documentation,但我仍然不知道发生了什么,可能出现了什么问题。
答案 0 :(得分:0)
我以这种方式管理它,我将文件移至\src\main\resources\git.properties
位置,并在此处添加了/
:
@PropertySource("classpath:/git.properties")
。
我仍然不明白为什么,但它现在适用于JBoss和WebSphere。