Why isn’t Spring running my @Scheduled method?

add “task:annotation-driven” ? <beans> <!– XMLNS, XSD declarations omitted for brevity –> <context:component-scan base-package=”com.mypackage”/> <task:annotation-driven/> <task:executor id=”executor” pool-size=”5″/> <task:scheduler id=”scheduler” pool-size=”5″/> <task:annotation-driven scheduler=”scheduler” executor=”executor”/> </beans> reference http://howtodoinjava.com/2013/04/23/4-ways-to-schedule-tasks-in-spring-3-scheduled-example/ or Spring @Configuration (non-xml configuration) for annotation-driven tasks Just add @EnableScheduling on you WebMvcConfig class @Configuration @EnableWebMvc @EnableAsync @EnableScheduling public class WebMvcConfig extends WebMvcConfigurerAdapter { /** Annotations config … Read more

How to know original class name if wrapped into proxy by Spring?

Spring provides a utility for this. http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/ClassUtils.html#getUserClass-java.lang.Class- public static Class<?> getUserClass(Class<?> clazz) “Return the user-defined class for the given class: usually simply the given class, but the original class in case of a CGLIB-generated subclass.”

How to test Spring @EventListener method?

First, As you’re using Spring Boot, the testing of these becomes pretty straightforward. This test will spin up the boot context and inject a real instance of ApplicationEventPublisher, but create a mocked instance of SomeDependency. The test publishes the desired event, and verifies that your mock was invoked as you expected. @RunWith(SpringRunner.class) @SpringBootTest public class … Read more

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration

This is caused by non-matching Spring Boot dependencies. Check your classpath to find the offending resources. You have explicitly included version 1.1.8.RELEASE, but you have also included 3 other projects. Those likely contain different Spring Boot versions, leading to this error.

Converting empty String to null Date object with Spring

Spring provides a PropertyEditor named CustomDateEditor which you can configure to convert an empty String to a null value. You typically have to register it in a @InitBinder method of your controller: @InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd”); dateFormat.setLenient(false); // true passed to CustomDateEditor constructor means convert empty String to … Read more

Spring Prototype scoped bean in a singleton

From Spring documentation: You do not need to use the <aop:scoped-proxy/> in conjunction with beans that are scoped as singletons or prototypes. If you try to create a scoped proxy for a singleton bean, the BeanCreationException is raised. It seems the documentation has changed a bit for version 3.2 documentation where you can find this … Read more

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