Why do I get a not exposed to the weaver warnings when making my Spring project?

萝らか妹 提交于 2019-12-04 02:17:05
Stephen C

What are they (What's the effect)?

It (ajc) is saying that it has found some class that it thinks ought to be or to have been "woven", but that can't be done / hasn't been done.

Should I be concerned about them?

Yes. It would mean that the AspectJ compile time weaving won't happen properly; i.e. the annotations on some classes won't take effect.

What can I do to remove them?

Change your build configs so that the weaver can find all of the code it needs to weave.

I'm guessing that your application involves multiple Maven modules. If so, then this Answer has some links to the relevant Eclipse/AspectJ and Maven documentation: https://stackoverflow.com/a/13120709/139985. It seems that the AspectJ Maven plugin needs to be explicitly told where to look for stuff.

I had a similar problem. On closer inspection, I realized that the warnings were happening during the test-compile phase only, where aspectj was not smart enough to automatically look in the main java source directory as well as in the test source directory. I solved it by splitting the two goals into separate executions, with different configurations. The relevant part of the POM is given below:

        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.10</version>
        <configuration>
          <complianceLevel>1.8</complianceLevel>
          <aspectLibraries>
            <aspectLibrary>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
            </aspectLibrary>
          </aspectLibraries>
          <source>1.8</source>
          <target>1.8</target>  
        </configuration>
        <executions>
          <execution>
            <id>compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <!-- add explicit instructions for test compile or it can't weave main src classes -->
          <execution>
            <id>test-compile</id>
            <configuration>
                <goals>
                    <goal>test-compile</goal>           
                    <sources>
                        <basedir>${project.basedir}</basedir>
                        <includes>
                            <include>src/main/java/**/*.java</include>
                            <include>src/test/java/**/*.java</include>
                        </includes>
                    </sources>
                </goals>
            </configuration>
        </execution>
        </executions>
    </plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!