Reputation: 1516
I am trying to do simple CRUD application by using Hibernate and SpringBoot. I want hibernate to create db automatically and show the sql statements therefore I added some properties in application.properties.
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto = create-drop
But all of them seems unused property. I tried to create configuration class and also added @PropertySource("classpath:application.properties")
but it did not help.
Here my configuration class:
@Configuration
@EnableAutoConfiguration
@ComponentScan
@EnableJpaRepositories
public class DBConfiguration {
}
Here is my main class:
@SpringBootApplication
@Import({DBConfiguration.class})
@PropertySource("classpath:application.properties")
public class SpringboothibernateApplication {
public static void main(String[] args) {
SpringApplication.run(SpringboothibernateApplication.class, args);
}
}
What I am doing wrong why application.properties file is unused at all.
Upvotes: 1
Views: 4415
Reputation: 11
Restarting STS/Eclipse has solved the problem for me. After restart, it is taking the updated values from application.properties.
Upvotes: 0
Reputation: 121
Delete the DbConfiguration. Write those properties in application.properties file which is located in resource folder. then use @EnableAutoConfiguration annotation on SpringBoothibernateApplication class.
Upvotes: 3