Could not write JSON: Infinite recursion (StackOverflowError); nested exception spring boot

You are facing this issue because the Statemaster model contains the object of Districtmaster model, which itself contains the object of Statemaster model. This causes an infinite json recursion. You can solve this issue by 3 methods. 1 – Create a DTO and include only the fields that you want to display in the response. … Read more

Multiple data source and schema creation in Spring Boot

spring.jpa.hibernate.ddl-auto=create has stopped working, not because you have two DataSources, but because your application’s creating its own LocalContainerEntityManagerFactoryBeans. This has the effect of disabling the auto-configuration of a LocalContainerEntityManagerFactoryBean so you now have to configure it yourself. You can configure the two entity managers to have different schema generation behaviour like this (the first’s doing … Read more

How do I create beans programmatically in Spring Boot?

How about creating your beans and ask Spring Boot to inject values into it? Something like @Bean @ConfigurationProperties(“ds.client1”) public DataSource dataSourceClient1() { DataSourceBuilder.create().build(); } @Bean @ConfigurationProperties(“ds.client2”) public DataSource dataSourceClient2() { DataSourceBuilder.create().build(); } Then, any setting in the ds.client1 namespace belongs to the first data source (i.e. ds.client1.password is the data source password for that DataSource). … Read more

Spring Boot with embedded Tomcat behind Apache proxy

I had the same problem the other day. After some debugging of Spring Boot 1.3 I found the following solution. 1. You have to setup the headers on your Apache proxy: <VirtualHost *:443> ServerName www.myapp.org ProxyPass / http://127.0.0.1:8080/ RequestHeader set X-Forwarded-Proto https RequestHeader set X-Forwarded-Port 443 ProxyPreserveHost On … (SSL directives omitted for readability) </VirtualHost> … Read more

Precedence order among properties file, YAML file, and Command Line arguments in SpringBoot

Spring Boot property resolution property order is described here. Use of application.properties and application.yaml is not expected. Use one format or the other but not both. Whichever one you use will be handled at position 12 or 13 (depending on whether the file is packaged in the application JAR or not) in property precedence order. … Read more