Home > Back-end >  Eclipse is copying an empty application.properties to target/classes (spring boot)
Eclipse is copying an empty application.properties to target/classes (spring boot)

Time:12-15

I'm facing a problem with this specific project, the resultant target/classes/application.properties is copied as an empty one when I update the src/main/resources/application.properties.

For this project I'm using two datasources/jpa configs, following the same format as the following:

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = { PJE_BPMN_PACKAGES }, entityManagerFactoryRef = PJE_BPMN_EMF, transactionManagerRef = PJE_BPMN_TM)
public class PjeBpmnDbConfig {
    @Autowired
    private Environment env;

    @Primary
    @Bean(name = PJE_BPMN_DS)
    @ConfigurationProperties(prefix = "pjebpmn.datasource")
    public DataSource createDataSource() {
        return DataSourceBuilder.create().build();
    }


    @Bean(name = PJE_BPMN_EMF)
    @Primary
    @ConfigurationProperties(prefix = "pjebpmn.jpa")
    public LocalContainerEntityManagerFactoryBean createEntityManager(EntityManagerFactoryBuilder entityManagerFactoryBuilder,
            @Qualifier(PJE_BPMN_DS) DataSource dataSource) {

        Map<String, String> properties = new HashMap<>();
        System.out.println(
                "lendo pjebpmn.jpa.hibernate.ddl-auto do properties, e retornou: "   env.getProperty("pjebpmn.jpa.hibernate.ddl-auto", "NADA"));
        properties.put("hibernate.hbm2ddl.auto", env.getProperty("pjebpmn.jpa.hibernate.ddl-auto", "update"));
        properties.put("hibernate.dialect", env.getProperty("pjebpmn.jpa.properties.hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"));

        return entityManagerFactoryBuilder.dataSource(dataSource).packages(PJE_BPMN_PACKAGES).persistenceUnit(PJE_BPMN_DS).properties(properties)
                .build();
    }

    @Primary
    @Bean(name = PJE_BPMN_TM)
    public PlatformTransactionManager createTransactionManager(@Qualifier(PJE_BPMN_EMF) EntityManagerFactory entityManagerFactory) {

        JpaTransactionManager transactionManager = new JpaTransactionManager(entityManagerFactory);
        return transactionManager;
    }

}

In the pom.xml, I'm using the start.spring.io generated, with spring-boot-starter-data-jpa, spring-boot-starter-web, lombok, spring-boot-devtools, spring-boot-configuration-processor and postgresql dependencis.

Whats wrong?

PS: I activated the Eclipse > Preferences > Maven > Annotation Processing > "Experimental" option, and the deactivated moments later.

Environment:

  • Mac Os catalina
  • Eclipse 2022-09
  • Sprint boot 2.7.6

I've tried with no success:

  • delete project from eclipse and eclipse files (.project, .settings, etc) and import as an "existing MVN project"
  • remove lombok and spring-boot-configuration-processor from pom.xml

CodePudding user response:

A friend from work, Simão, help me to find the problem.

I don't know how or why but in Eclipse inside Project properties > Java Build Path > tab Source > source folders on build path > project/src/main/resources, the option Excluded was Excluded: **, where is supposed to be Excluded: none

Excluded option

I expected that the application.properties wasn't copied at all, instead of a empty copy of it.

  • Related