How to use with an tag?

<spring:url value=”/something” var=”url” htmlEscape=”true”/> <a href=”${url}”>…</a> But you an also use c:url <c:url value=”/something” var=”url”/> <a href=”<c:out value=”${url}”/>”>…</a> The one important difference between c:url and spring:url is, that c:url does not html encode the created url. But for a valid url the & between the url parameters must be a &amp;. So you need the … Read more

spring – hibernate 5 naming strategy configuration

I think I found the solution. To achieve my goal, I used hibernate.physical_naming_strategy configuration, instead of hibernate.implicit_naming_strategy. I created an implementation of the PhysicalNamingStrategy interface which simulates part of the functionality of the original ImprovedNamingStrategy class: package fms.util.hibernate; import org.apache.commons.lang.StringUtils; import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.PhysicalNamingStrategy; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; public class ImprovedNamingStrategy implements PhysicalNamingStrategy { @Override public Identifier … Read more

Can we declare spring bean conditionally?

You can use @Conditional from Spring4 or @ConditionalOnProperty from Spring Boot. Using Spring4 (only) if you are NOT using Spring Boot, this can be overkill. First, create a Condition class, in which the ConditionContext has access to the Environment: public class MyCondition implements Condition { @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment env … Read more

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

Load balancer does not have available server for client

After doing research, and with help of @Bloodysock, I found that I was missing registration of remote server in ‘client-app’ micro-service. The document is at Spring Cloud Netflix. I used Ribbon without Eureka with configuration in application.yml in ‘client-app‘ micro-service as: movie-api: ribbon: listOfServers: http://localhost:8090

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

Spring @Async limit number of threads

If you are using Spring’s Java-configuration, your config class needs to implements AsyncConfigurer: @Configuration @EnableAsync public class AppConfig implements AsyncConfigurer { […] @Override public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(2); executor.setMaxPoolSize(5); executor.setQueueCapacity(50); executor.setThreadNamePrefix(“MyExecutor-“); executor.initialize(); return executor; } } See @EnableAsync documentation for more details :

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