- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我添加了一个 github 存储库,它准确地显示了我的问题:
https://github.com/runefist/AspectJ-Stackoverflow-Q
<小时/>简而言之,我有一个项目,我们将其称为 ProjectA。 ProjectA 是一个 microprofile-REST-服务器。另一个项目(我们称之为 ProjectB)是 ProjectA(和其他项目)的依赖项。
ProjectB 包含一个方面:
@Aspect
public class ElasticSenderAspect {
@After("@annotation(elasticsender)") // && execution(* *(..))
public void after(JoinPoint joinPoint, ElasticSender elasticsender) {
WebsiteBehaviour websiteBehaviour = new WebsiteBehaviour();
websiteBehaviour.setBehaviourFunc(elasticsender.behaviourFunction());
websiteBehaviour.setBehaviourType(elasticsender.behaviourType());
ElasticWebsiteBehaviour.sendWebsiteBehaviour(websiteBehaviour);
}
}
在 ProjectA 中我有一个函数:
@GET
@Operation(description = "Authenticate")
@ElasticSender(behaviourFunction = "Authenticate")
public Response authenticate(@HeaderParam("authorization") String authString) {
if (authString == null) {
return StandardResponseMessages.GENERAL_NO_AUTHENTICATION.getResponse();
}
WebAccount webAccount = webAccountService.find(getUsernameFromAuth(authString));
boolean correct = false;
//TODO: CHECK IF ACCOUNT IS VERIFIED
if (webAccount != null) {
if (webAccount.getUsername() != null && webAccount.getPassword() != null) {
if (AuthenticatorUtility.basicAuthenticate(webAccount.getUsername(), webAccount.getPassword(), authString)) {
correct = true;
}
}
}
if (correct) {
return Response.ok(generateTokenString(webAccount)).build();
} else {
return StandardResponseMessages.GENERAL_WRONG_AUTHENTICATION.getResponse();
}
}
我已经测试了该方面,当我在同一个项目中使用它时它可以工作,所以不作为依赖项。
项目A - pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>com.runefist</groupId>
<artifactId>FeestjesDoen-Server</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>FeestjesDoen-Server</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>BendingHeroes-repo</id>
<url>xxx</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<!-- MAIN DEPENDENCY -->
<dependency>
<groupId>com.runefist</groupId>
<artifactId>WebRest-Utilities</artifactId>
<version>1.0.0</version>
</dependency>
<!-- MICROPROFILE SWAGGER UI -->
<dependency>
<groupId>org.microprofile-ext.openapi-ext</groupId>
<artifactId>swagger-ui</artifactId>
<version>1.0.1</version>
<scope>runtime</scope>
</dependency>
<!-- KAFKA NEEDED -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<showWeaveInfo>true</showWeaveInfo>
<encoding>UTF-8 </encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
项目B - pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>com.runefist</groupId>
<artifactId>WebRest-Utilities</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- MICROPROFILE REPLACES JAVAEE -->
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>2.1</version>
<type>pom</type>
</dependency>
<!-- FOR CREATING JWT TOKENS -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
<type>jar</type>
</dependency>
<!-- FOR THE USE OF HIBERNATE -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.3.1.Final</version>
</dependency>
<!-- MYSQL CONNECTOR FOR HIBERNATE -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
<scope>compile</scope>
</dependency>
<!-- FOR JSON CONVERSION -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<!-- ElasticSearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.5.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.5.4</version>
<type>jar</type>
</dependency>
<!-- AspectJ | to add behaviour to methods -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.2</version>
</dependency>
<!-- Junit - TEMP added to test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<goals>
<!--use this goal to weave all your main classes-->
<goal>compile</goal>
<!--use this goal to weave all your test classes-->
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<!-- put your configurations here -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
问题:
在 ProjectB 中测试时,方面会发生,在 ProjectA 中测试时,方面不会发生。我需要向 ProjectA pom 添加什么才能使其工作,或者我需要对 ProjectB pom 进行哪些更改才能使其工作?
最佳答案
在项目 A 中,您需要将 B 添加为 aspect library除了像您已经做的那样将其添加为 Maven 依赖项之外,还可以在 AspectJ Maven 配置中添加它:
<configuration>
<!-- (...) -->
<aspectLibraries>
<aspectLibrary>
<groupId>com.runefist</groupId>
<artifactId>ProjectB</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
我克隆并测试了你的项目,它是这样工作的。
关于java - AspectJ - 来自外部 JAR 的方面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54707562/
我对构面有疑问,并根据构面进行了一些过滤。 我知道这是一个重复的问题,但我找不到答案。 我想知道如何在 flex 搜索中实现相同的功能。 假设我有一个有关汽车和某些方面的索引-例如模型和 颜色。 颜色
我正在尝试找到一种解决方案来为某些方面创建子方面列表。 我有一些产品的衣服尺码,它们存储在 solr 中 "Size_both":"W30L30","尺寸宽度":"W30","Size_length"
我正在尝试找到一种解决方案来为某些方面创建子方面列表。 我有一些产品的衣服尺码,它们存储在 solr 中 "Size_both":"W30L30","尺寸宽度":"W30","Size_length"
我对方面有疑问。他们不开火。我有小方面: @Aspect @Component public class SynchronizingAspect { @Pointcut("execution(
这是在 ruby 中启用散列自动生成的巧妙技巧(取自 facets): # File lib/core/facets/hash/autonew.rb, line 19 def self.a
这个问题在这里已经有了答案: 8年前关闭。 Possible Duplicate: Creating a facet_wrap plot with ggplot2 with different ann
XMLHttpRequest 能否从 http://mydomain.example/ 向 http://mydomain.example:81/ 发送请求? 最佳答案 要使两个文档被视为具有相同的来
我对 Elasticsearch 中的方面有一点问题。 我有一个表格视频,一个表格 channel ,一个 channel 有很多视频。 我只想在 X 个最新视频上显示每个 channel 的 %vi
假设我正在为 4 个人绘制数据图表:Alice、Bob、Chuck 和 Dana。我正在使用 ggplot2 制作一个多面图,每个人一个方面。我的磁盘上还有 4 张图像:Alice.png、Bob.p
我已经下载了收件箱,并且正在使用Pig和Hadoop处理电子邮件。我已经使用Pig和Wonderdog在ElasticSearch中为这些电子邮件编制了索引。 现在,我为收件箱中的每个电子邮件地址创建
我有一个模块如下: define([...], function(...){ function anothermethod() {...} function request() {....}
(defprotocol IAnimal "IAnimal" (report [o] (println (type o) " reporting.\n") (inner-repor
我有一个 Bean 需要向 InfluxDB 报告。数据库在表 INFLUX_DB_SERVER 中注册了 InfluxDB。如果你看一下代码,你会发现方法reportMemory做了很多工作,它构造
我的问题与分面有关。在下面的示例代码中,我查看了一些分面散点图,然后尝试在每个分面的基础上叠加信息(在本例中为平均线)。 tl;dr 版本是我的尝试失败了。要么我添加的平均线计算所有数据(不尊重方面变
假设我正在为 4 个人绘制数据图表:Alice、Bob、Chuck 和 Dana。我正在使用 ggplot2 制作一个多面图,每个人一个方面。我的磁盘上还有 4 张图像:Alice.png、Bob.p
尝试用两个方面包装服务类来获取此调用链: javanica..HystrixCommandAspect -> MyCustomAroundAspect -> MyService 遇到两个问题: Hys
我是 AspectJ 的初学者。我用它在我的网络驱动程序中截取屏幕截图。以下是我的包结构。 我想知道如何在 Browser 类中运行我的程序,以便它使用 Screenshots 类中定义的 Aspec
我在使用 spring aop 时遇到问题 (编辑:如果我的方法不是静态的,则代码可以正常工作) 我的包中有这个结构: aaa.bbb.ccc.Clase1.java aaa.bbb.ddd.Clas
我有一个通用存储库类,其中包含各种标记有 PostSharp 方面 (SecuredOperation) 的方法... public class Repository : IRepository, I
我有一个运行多线程的 Hibernate 事务方法“doImportImpl”。而某些记录需要依次导入,所以代码结构大致是这样的: public RecordResult doImportImpl(S
我是一名优秀的程序员,十分优秀!