Spring nie może znaleźć pliku properties po zmianach w nim

0

Cześć
Mam aplikację springową. Problem jest taki , że po zmianie w pliku dev-property.properties, w którym przechowywane są ustawienia do baz itp. to przy starcie aplikacji dostaję :

nested exception is java.io.FileNotFoundException: class path resource [develop/dev-property.properties] cannot be opened because it does not exist
19:44:42.155 ERROR --- [ main] o.s.boot.SpringApplication : Application startup failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [pl.property.web.config.AppConfig]; nested exception is java.io.FileNotFoundException: class path resource [develop/dev-property.properties] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:182)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at pl.property.web.Application.main(Application.java:26)
Caused by: java.io.FileNotFoundException: class path resource [develop/dev-property.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:153)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:72)
at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:58)
at org.springframework.core.io.support.ResourcePropertySource.<init>(ResourcePropertySource.java:84)
at org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:367)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:255)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:232)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:191)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:272)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:232)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:168)
... 13 common frames omitted
19:44:42.155 INFO --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/charsets.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/deploy.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jdk1.8.0_151/jre/lib/ext/sunpkcs11.jar
................

Dopiero w momencie, gdy zrobię mvn clean install to zadziała, chociaż też nie zawsze. Czasem dopiero za drugim razem działa.
Klasa AppConfig

@Configuration
@ComponentScan("pl.property.web")
@Import({ServicesConfig.class, DatabaseConfig.class,
        WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        FallbackWebSecurityAutoConfiguration.class,
        SecurityFilterAutoConfiguration.class
})
@EnableScheduling
@EnablePolonEnvironment
@EnablePolonProfiling
@PropertySources({ @PropertySource("classpath:property.properties")})
public class AppConfig {

    @Bean
    public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper objectMapper = new ObjectMapper(null, new PropertySerializerProvider(), null);
        objectMapper.setDateFormat(new SimpleDateFormat("dd-MM-yyyy"));
        objectMapper.registerModule(new PropertyModule());
        return objectMapper;
    }

    @Bean
    public TypeConverter typeConverter() {
        return new TypeConverter();
    }

    @Bean
    public WidgetDataSerializer dataSerializer(ObjectMapper objectMapper) {
        return new JacksonWidgetDataSerializer(objectMapper);
    }

    @Bean
    public BundleMutex bundleMutex() {
        return new BundleMutex(4000);
    }
}

I konfiguracja profilu develop

@Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class, ServerPropertiesAutoConfiguration.class })
public class DeveloperConfig {

    @Configuration
    @Profile("develop")
    public static class DevConfig {

        @Bean
        public EmbeddedServletContainerCustomizer welcomePageSetter() {
            return container -> ((TomcatEmbeddedServletContainerFactory) container)
                    .addContextCustomizers(context -> context.addWelcomeFile("index.html"));
        }

        @Configuration
        @Profile("develop")
        @PropertySource("classpath:develop/dev-property.properties")
        static class DevProperties {
        }

    }

}

Ktoś ma jakieś pomysły czym to może być spowodowane? Inne osoby w zespole nie mają z tym problemu

0

no dobrze... zmieniłeś ścieżkę, może zrób crtl-z i zobacz co zmieniłeś na co?

jak się ma to z profilu:

@PropertySource("classpath : develop/dev-property.properties")

do tego z AppConfig:

@PropertySources({ @PropertySource("classpath : property.properties")})

to nie powinno być to samo?
nie znam dobrze springa, ale zdaje mi się, że ustawienia profilów i samej apki mogą mieć związek

0

Ścieżki nie zmieniłem. Zmieniłem jedynie coś w tym dev..
Napisałem wcześniej, że nie ważne co zmieniam w dev.. np. czy przełączam sobie bazę pomiędzy środowiskami, czy połączenia do systemów zewnętrznych, z którymi się komunikujemy efekt jest zawsze taki sam dev.. not found. Ustawień w AppConfig i DeveloperConfig nie mogę zmienić, bo przecież u innych działa....
Nie musi być to samo bo mamy kilka plików konfiguracyjnych, property.properties dla każdego profilu, a w tym przypadku dla developa dev.properties

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0