Entries

org.postgresql.util.PSQLException: This connection has been closed in Spring Boot

In Spring Boot data source connection pooling is auto-configured if a proper JDBC Driver is used (e.g. org.postgresql.Driver ) and by default Tomcat pooling is used - although it can be easily changed). But the default configuration may not be enough in the production environment. One of the issues I had was org.postgresql.util.PSQLException: This connection has been closed exception after Postgres database was restarted while the application was running. In order to restore the connection application restart is needed.

5 reasons why you should consider upgrading your applications to Spring 4

Firstly released in 2004, Spring Framework is among top Java frameworks. Spring 4 has been released in December 2013 and it is the first version of framework to support Java 8. Learn why you should consider upgrading your applications to Spring 4.

Learn REST with Spring

The popularity of REST-style APIs is not decreasing so a good knowledge in this architecture style becomes essential in many projects. In Java, there are many frameworks that you as a developer can utilize in order to build a REST-style API, with Spring MVC as one of the most popular. If you wish to learn how to work effectively with REST in Spring you definitely need some good learning materials.

Spring Boot with Gradle and resource filtering

Recently, while working on a rather small Spring Boot web application, I encountered an issue: after the deployment of a WAR file the application did not serve fonts and and other binary files properly. And the issue was with the invalid configuration of resource filtering in Gradle.

HOW-TO: Register components using @Conditional and Condition in Spring

@Profile annotation in Spring can be used on any Spring components (e.g. @Component , @Service , @Configuration etc.) that are candidates for auto-detection. @Profile annotation accepts a single profile or a set of profiles that must be active in order to make the annotated component eligible for auto-detection. For a given @Profile({"p1", "!p2"}) , registration will occur if profile p1 is active or if profile p2 is not active. The or is crucial here. But how to achieve this with @Profile : we want to activate a given component if profile p1 is active and if profiles p2 and p3 are both inactive?