Spring Boot Configure and Use Two DataSources

How can I configure and use two data sources? For example here is what I have for the first data source: application.properties #first db spring.datasource.url = [url] spring.datasource.username = [username] spring.datasource.password = [password] spring.datasource.driverClassName = oracle.jdbc.OracleDriver #second db … Application class @SpringBootApplication public class SampleApplication { public static void main(String[] args) { SpringApplication.run(SampleApplication.class, args); } … Read more

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set

I am trying run a spring-boot application which uses hibernate via spring-jpa, but i am getting this error: Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104) at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:205) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842) … Read more

How to access a value defined in the application.properties file in Spring Boot

I want to access values provided in application.properties, e.g.: logging.level.org.springframework.web: DEBUG logging.level.org.hibernate: ERROR logging.file=${HOME}/application.log userBucket.path=${HOME}/bucket I want to access userBucket.path in my main program in a Spring Boot application. 32 Answers 32 You can use the @Value annotation and access the property in whichever Spring bean you’re using @Value(“${userBucket.path}”) private String userBucketPath; The Externalized Configuration … Read more

How to log SQL statements in Spring Boot?

I want to log SQL statements in a file. I have the following properties in application.properties spring.datasource.url=… spring.datasource.username=user spring.datasource.password=1234 spring.datasource.driver-class-name=net.sourceforge.jtds.jdbc.Driver spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true security.ignored=true security.basic.enabled=false logging.level.org.springframework.web=INFO logging.level.org.hibernate=INFO logging.file=c:/temp/my-log/app.log When I run my application cmd>mvn spring-boot:run I can see sql statements in the console but they don’t appear in a file app.log. The file contains only basic … Read more

Spring Boot – Unable to resolve Whitelabel Error Page

Please define method in your controller: You may define @RequestMapping(value = “/”, method = RequestMethod.GET) or you may directly use @GetMapping @Controller public class LoginController { @GetMapping(path=”/”) public String login() { System.out.println(“******************logging************************”); return “login”; } } there might be some more conflicts in your pom, like no need add tomcat dependency as its already embedded so below … Read more