I have the following eof bean:
@Configuration
@EnableJpaRepositories("....repositories")
public class JpaConfig {
...
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
JpaVendorAdapter jpaVendorAdapter,
Properties jpaProperties) {
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setDataSource(dataSource);
entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter);
entityManagerFactory.setPackagesToScan("....entities");
entityManagerFactory.setJpaProperties(jpaProperties);
return entityManagerFactory;
}
}
And it works perfect (even with declared aop dependencies) until I add an aspect to my project. After marking the aspect as a component I get the following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [.../configs/JpaConfig.class]: No matching factory method found: factory bean 'jpaConfig'; factory method 'entityManagerFactory()'. Check that a method with the specified name exists and that it is non-static.
Here's my Maven dependencies:
<!--AOP-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.9</version>
</dependency>
<!--Data-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.10.1.RELEASE</version>
</dependency>
<!--Database-->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1208.jre7</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.5</version>
<scope>compile</scope>
</dependency>
Will provide additional information on request. Thank you very much.
Update Aspect:
@Aspect
@Component
public class TestAspect {
@Before("execution(public * *(..))")
public void test() {
System.out.println("Public Method invoked");
}
}
Update What's interesting is that this aspect works and prints test strings.