dsyer / spring-boot-aspectj

Sample applications showing how to use AspectJ with Spring Boot
https://projects.spring.io/spring-boot/
169 stars 52 forks source link

Example of Spring Transaction AspectJ On Spring Boot #4

Open hendratommy opened 5 years ago

hendratommy commented 5 years ago

It would be great if there is an definitive example how to configure Spring Transaction (AspectJ mode), the current documentation seems confusing. It would be great if you can provide one.

I have an application based on Spring Boot 2.0.x, its running fine but when upgrading to 2.1.x its producing many error output at startup saying error can't determine implemented interfaces which causing slow start up:

[LaunchedURLClassLoader@5fcfe4b2] error can't determine implemented interfaces of missing type net.sf.ehcache.CacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes
when weaving
 [Xlint:cantFindType]
[LaunchedURLClassLoader@5fcfe4b2] error can't determine implemented interfaces of missing type net.sf.ehcache.CacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes
when weaving

And seems like I'm not the only one:

I get it to working by having the spring transaction in aop.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
    <weaver>
        <include within="com.my.app..*" />
        <include within="org.springframework.transaction..*" />
    </weaver>
</aspectj>

But I left wondering if this is the correct way, since many other package do not get woven did i miss something that i do not aware of?

adminy commented 2 years ago

I got the same error running a different java version for compiling the aspects than the application java version.