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>

@EnableTransactionManagement annotation with 2 transaction managers

In your configuration class, use @EnableTransactionManagement annotation. Define a transaction manager in this class as: @Bean(name=”txName”) public HibernateTransactionManager txName() throws IOException{ HibernateTransactionManager txName= new HibernateTransactionManager(); txName.setSessionFactory(…); txName.setDataSource(…); return txName; } There on, in your class/method that executes transactional job(s), annotate as follows: @Transactional(“txName”) or @Transactional(value = “txName”) This is how you would tie a name … Read more

Spring Security @PreAuthorization pass enums in directly

Indeed you can implement a custom strongly typed security annotation, though this is rather bothersome. Declare your annotation enum Permission { USER_LIST, USER_EDIT, USER_ADD, USER_ROLE_EDIT } @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @interface Permissions { Permission[] value(); } Declare the custom implementation of org.springframework.security.access.ConfigAttribute to be used by security pipeline class SecurityAttribute implements ConfigAttribute { private final List<Permission> permissions; … Read more

Dynamically changing the @ResponseStatus in annotation driven Spring MVC

@ResponseStatus(HttpStatus.OK) means that the request will return OK if the handling method returns normally (this annotation is redundant for this case, as the default response status is HttpStatus.OK). If the method throws an exception, the annotation does not apply; instead, the status will be determined by Spring using an exception handler. How can I handle … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)