首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >连接到spring AspectJ项目时的工作流

连接到spring AspectJ项目时的工作流
EN

Stack Overflow用户
提问于 2021-09-17 10:14:47
回答 1查看 66关注 0票数 0

同事们。

我连接aspects,原生ajc编译器。使用的想法: Intelleje Idea

项目中的技术:

代码语言:javascript
复制
Maven
Spring boot
Lombok

问题:尝试使用上述技术的集成堆栈运行aspectj for java16。+用于自动组装项目以在jar中构建工作方面的框架

我试过了:

代码语言:javascript
复制
1. plugin for automated project building "org.codehaus.mojo" works only with Java 1.8, I cannot use later versions. As I understand it, the plugin is outdated.

2. Including aspectjrt in project dependencies and assigning aspectjtools and aspectjweawer to the project facet

3. Various manipulations with installing the Java version in ide

结果:

代码语言:javascript
复制
1. Works but target is not achieved (java before 8)
2. Does not work
3. Does not work

花时间研究材料: 2-3周,收集了一堆文章和网络资源。我还可以读一读书“casually in action”

我附加了一个pom文件和一个工作插件:

代码语言:javascript
复制
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>MyAopWithoutSpring</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!--    <parent>-->
    <!--        <groupId>com.baeldung</groupId>-->
    <!--        <artifactId>parent-boot-2</artifactId>-->
    <!--        <version>0.0.1-SNAPSHOT</version>-->
    <!--        <relativePath>../parent-boot-2</relativePath>-->
    <!--    </parent>-->
    <!--    <parent>-->
    <!--        -->
    <!--    </parent>-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>${aspectj-plugin.version}</version>
                <configuration>
                    <complianceLevel>${java.version}</complianceLevel>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <showWeaveInfo>true</showWeaveInfo>
                    <verbose>true</verbose>
                    <Xlint>ignore</Xlint>
                    <encoding>UTF-8</encoding>
                    <excludes>
                        <exclude>**/pointcutadvice/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <aspectj-plugin.version>1.11</aspectj-plugin.version>
        <java.version>1.8</java.version>
    </properties>

</project> ```

To be honest, I am already ready to despair, I do not understand the sequence of actions at all in order for it to somehow work on the technology stack that is necessary. I will be glad to any advice and tips from more experienced colleagues
EN

回答 1

Stack Overflow用户

发布于 2021-10-14 08:37:30

  • 1.14.0版的MojoHaus AspectJ Maven插件支持Java 16。
  • 1.13.1版的AspectJ.dev AspectJ Maven Plugin具有附加功能,支持Java 16和17,并且可以配置为支持17以上的未来Java和AspectJ版本。
  • 这两个插件都已依赖于aspectjtools中包含的

编译器,如果需要特定版本,您可以升级或降级该编译器。在使用编译时编织时,您需要添加D10。因为运行支持AspectJ的程序需要一个小插件,所以runtime.

  • IntelliJ IDEA有针对"AspectJ“(marketplace,作者JetBrains)和"AOP Pointcut Language”(捆绑)的插件。您可以安装这两个插件以获得对AspectJ语法和Eclipse Maven插件(上面提到的两个变体)的支持。
  • 当组合AspectJ和Lombok时,请注意可能出现的问题,因为它们都以不同的方式派生Eclipse Java编译器。这些问题可以通过编织delomboked源代码来解决,或者首先使用javac应用Lombok,然后添加额外的AspectJ二进制编织构建步骤。请参阅herehere
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69221666

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档