Spring
Spring Boot Configuration Best Practices
Customizing REST API Error Response in Spring Boot / Spring-Security-OAuth2
Defining error format is important part of REST API design.
Spring-Boot and Spring Security provide pretty nice error handling for RESTful APIs out of the box. Although it has to be documented, especially when contract-first approach to API design is used.
It is good idea to follow some common format for error responses. But OAuth2 specification and Spring Boot format may not satisfy those requirements.
Spring+Freemarker Tips
I hope you will find following tips useful when developing Spring Boot application with Freemarker.
Booting Spring Webapp
Spring Boot is an excellent tool to bootstrap java application. Most of the references mention how to create a standalone java application, optionally with embedded web server (tomcat or jetty). But Spring Boot supports also creating web applications intended to run within servlet container.
Conditional Java Configurations in Spring Framework
Spring Framework offers very flexible means for binding application components. Externalizable properties, composite configuration, nested application contexts and profiles.
Sometimes, it is necessary to control whether particular beans or @Configuration
will be loaded or not. Spring Framework v.4.1.x does not provide that feature out of the box. But, hopefully, Spring allows conditional bean initialization (see @Profile
implementation and @Configurable
).
So, I created the annotation @Enabled
which allows me to control bean instantiation via properties.
@Enabled
indicates that a component is eligible for registration when evaluated expression is true. This annotation should be used in conjunction with Configuration and Bean annotations.
JAX-WS with Custom SSLSocketFactory
It’s very easy to configure custom SSLSocketFactory for JAX-WS web-service: just specify custom property referring to SSLSocketFactory
bean.
But there is a nuance…
Establishing Customizable Tomcat Configuration
Deploying to Apache Tomcat often requires making changes to default configuration. These changes are often environment specific. Also, when upgrading a Tomcat to new version you need to be sure that all your custom changes have not been lost and were applied to new configuration. To deal with all that stuff Tomcat via separation of the configuration. This post contains step-by-step instruction will help you to establish custom tomcat configuration.