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

First remove all of your configuration Spring Boot will start it for you. Make sure you have an application.properties in your classpath and add the following properties. spring.datasource.url=jdbc:postgresql://localhost:5432/teste?charSet=LATIN1 spring.datasource.username=klebermo spring.datasource.password=123 spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect spring.jpa.show-sql=false spring.jpa.hibernate.ddl-auto=create If you really need access to a SessionFactory and that is basically for the same datasource, then you can do the following … Read more

Spring Boot and multiple external configuration files

UPDATE: As the behaviour of spring.config.location now overrides the default instead of adding to it. You need to use spring.config.additional-location to keep the defaults. This is a change in behaviour from 1.x to 2.x When using Spring Boot the properties are loaded in the following order (see Externalized Configuration in the Spring Boot reference guide). … Read more

Spring Boot Remove Whitelabel Error Page

You need to change your code to the following: @RestController public class IndexController implements ErrorController{ private static final String PATH = “/error”; @RequestMapping(value = PATH) public String error() { return “Error handling”; } @Override public String getErrorPath() { return PATH; } } Your code did not work, because Spring Boot automatically registers the BasicErrorController as … Read more

How to configure CORS in a Spring Boot + Spring Security application?

Spring Security can now leverage Spring MVC CORS support described in this blog post I wrote. To make it work, you need to explicitly enable CORS support at Spring Security level as following, otherwise CORS enabled requests may be blocked by Spring Security before reaching Spring MVC. If you are using controller level @CrossOrigin annotations, … Read more

Springboot Security hasRole not working

You have to name your authority with prefix ROLE_ to use isUserInRole, see Spring Security Reference: The HttpServletRequest.isUserInRole(String) will determine if SecurityContextHolder.getContext().getAuthentication().getAuthorities() contains a GrantedAuthority with the role passed into isUserInRole(String). Typically users should not pass in the “ROLE_” prefix into this method since it is added automatically. For example, if you want to determine … Read more

Spring Boot Configure and Use Two DataSources

Here you go. Add in your application.properties file: #first db spring.datasource.url = [url] spring.datasource.username = [username] spring.datasource.password = [password] spring.datasource.driverClassName = oracle.jdbc.OracleDriver #second db … spring.secondDatasource.url = [url] spring.secondDatasource.username = [username] spring.secondDatasource.password = [password] spring.secondDatasource.driverClassName = oracle.jdbc.OracleDriver Add in any class annotated with @Configuration the following methods: @Bean @Primary @ConfigurationProperties(prefix=”spring.datasource”) public DataSource primaryDataSource() { return … Read more

How to properly use findBySomeOtherId not findById in Spring data jpa?

Please use this InterviewStatus findByInterviewId(Interviews interviewId); where interviewId is gotten by running Interviews findById(Long id). Due to the datatype conflict, it is ok that you pass in as parameter the expected datatype. so it is expecting Interviews not Integer, but you have integer. in this case, you get Interviews using the integer then pass the … Read more

Converting List of long values to comma separated along with paranthesis around the each value

If you consider a List<String> with the above values then its a case of simple string manipulation; where you just need to iterate over all the list elements, and store in a new list. The idea is this: List<String> originalList = new ArrayList<String>(); originalList.add(“1234567”); originalList.add(“6789034”); originalList.add(“34534356”); List<String> modifiedList = new ArrayList<String>(); int listSize = originalList.size(); … Read more