Is it possible to wire a Spring MVC Interceptor using annotations?

Stumbled upon this question while searching exactly this. Finally I found out that it works in Spring 3.1 using @EnableWebMVC in conjunction with WebMvcConfigurerAdapter. Simple Example: @Configuration @EnableWebMvc @ComponentScan(basePackages=”webapp.base.package”) public class WebApplicationConfig extends WebMvcConfigurerAdapter { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoggerInterceptor()); } }

Authentication and authorization in Spring Data REST

The best bet for you is Spring Security. That would help you achieve authorization is much simpler manner. Spring Security would require you an implementation that looks at request headers and performs the log-in operation programmatically. Refer the accepted answer here.. I had followed the same and implemented the security layer in front of my … Read more

Spring 3.0.5 doesn’t evaluate @Value annotation from properties

Found what the issue was. Copy/paste from comments: Are you sure you have <context:property-placeholder> in the same application context as your MyClass bean (not in the parent context)? – axtavt You’re right. I moved <context:property-placeholder> from the context defined by the ContextLoaderListener to the servlet context. Now my values get parsed. Thanks a lot! – … Read more

Spring is losing connection to the DB and does not recover or reconnect

Per a senior member in the Spring forums, the Spring DataSource is not intended for production use: The above answers are only part of the solution. Indeed you need proper transaction managent AND you need a connection pool. The DriverManagerDataSource is NOT meant for production, it opens and closes a datebase connection each time it … Read more

Using Spring cache annotation in multiple modules

Use this class: http://static.springsource.org/autorepo/docs/spring/3.2.0.M1/api/org/springframework/cache/support/CompositeCacheManager.html like this: <cache:annotation-driven cache-manager=”cacheManager” /> <bean id=”cacheManager” class=”org.springframework.cache.support.CompositeCacheManager”> <property name=”cacheManagers”> <array> <ref bean=”cacheManager1″ /> <ref bean=”cacheManager2″ /> </array> </property> <property name=”addNoOpCache” value=”true” /> </bean>

How to remove the “_embedded” property in Spring HATEOAS

I close HAL feature, because it is hard to using Resources/Resource by restTemplate. I disable this feature by following code: public class SpringRestConfiguration implements RepositoryRestConfigurer { @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.setDefaultMediaType(MediaType.APPLICATION_JSON); config.useHalAsDefaultJsonMediaType(false); } } It work for me. HAL is good if there are more support with restTemplate.

spring-boot-starter-tomcat vs spring-boot-starter-web

Since #1 supports Tomcat why would one want to use #2? spring-boot-starter-web contains spring-boot-starter-tomcat. spring-boot-starter-tomcat could potentially be used on its own if spring mvc isn’t needed (contained in spring-boot-starter-web). Here is the dependency hierarchy of spring-boot-starter-web: What are the differences? spring-boot-starter-web contains spring web dependencies (including spring-boot-starter-tomcat): spring-boot-starter jackson spring-core spring-mvc spring-boot-starter-tomcat spring-boot-starter-tomcat contains … Read more

Spring MVC Controllers Return Type

It’s the same logic but it’s not the same version of spring. The ModelAndView object is the spring 2.x way of handling model and views. In the example you gave, the modelandview object will load the “helloWorld” view (depending on your templating engine could be helloWorld.jsp, or helloWorld.html, …) with one data “message” in the … Read more