Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法从JBoss-EAP-64上的@PropertySource读取配置文件_Java_Spring_Jboss_Websphere_Jboss6.x - Fatal编程技术网

Java 无法从JBoss-EAP-64上的@PropertySource读取配置文件

Java 无法从JBoss-EAP-64上的@PropertySource读取配置文件,java,spring,jboss,websphere,jboss6.x,Java,Spring,Jboss,Websphere,Jboss6.x,我正试图在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

我正试图在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();
    }
}

我已经读过了,但我仍然不知道发生了什么以及可能的错误。

我用这种方式管理它,我将文件移动到
\src\main\resources\git.properties
位置,
并在此处添加了
/
@PropertySource(“classpath:/git.properties”)



我仍然不明白为什么,但它现在可以在JBoss和WebSphere上运行。

classpath:git.properties在您的工作空间中不存在。复核it@Mạ新罕布什尔州奎伊ế唐古伊ễn这不是类路径,而是文件名。WebSphere没有问题,为什么JBoss?您的
classpath
没有引用相同的目录(
src/main/webapp
)。如果在
applicationContext.xml
文件中有正确的
classpath
,请尝试从该路径推断
git.properties