Не удалось прочитать файл конфигурации из @PropertySource на JBoss-EAP-64 - PullRequest
0 голосов
/ 19 мая 2018

Я пытаюсь запустить свое приложение на 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();
    }
}

Я прочитал документацию , но я до сих пор не знаю, что происходит и что может быть не так.

1 Ответ

0 голосов
/ 19 мая 2018

Мне удалось так, что я переместил файл в \src\main\resources\git.properties местоположение,
и добавил / здесь: @PropertySource("classpath:/git.properties").

Я до сих пор не понимаю, почему, но теперь он работает как на JBoss, так и на WebSphere.

...