作为迁移到 Java 8 和纪念 Spring 4 的一部分,我想我会升级到所有 64 位代码。此应用程序在 32 位上完美运行,但加载时间编织在 64 位上不起作用(实际上甚至不加载)。
架构细节:
在 Windows 上的 Spring Tool Suite 3.5.1 下测试。部署目标 RHEL
JVM启动:
-javaagent:C:\Users\...\.m2\repository\org\springframework\spring-instrument\4.0.5.RELEASE\spring-instrument-4.0.5.RELEASE.jar
Run Code Online (Sandbox Code Playgroud)
冒犯的Bean:
@Bean()
public LoadTimeWeaver loadTimeWeaver() {
return new org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver();
}
Run Code Online (Sandbox Code Playgroud)
错误很简单:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'entityManagerFactory' defined in class path resource com/xxxx/config/DataContextConfig.class]:
Invocation of init method failed; nested exception is java.lang.IllegalStateException:
Must start with Java agent to …Run Code Online (Sandbox Code Playgroud) 看看这个Eclipse Bug似乎Java Verifier(自1.6起)与ApsectJ存在问题.
错误说AspectJ 1.8.1将解决问题.但是在Java8u11中使用它仍然会得到验证错误.
我在STS 3.6.0(Eclipse 4.4)下运行JUnit4.我相信这个配置是所有软件包中最新的.
用请求的示例完全替换了剩下的文本.这似乎仅限于@Around建议. @Before工作正常.
JUnit的:
package com.test.aspectjdemo.junit;
import static org.junit.Assert.*;
import org.junit.Test;
import com.test.aspectjdemo.domain.AspectTarget;
public class AspectTargetTest {
@Test
public void testFirstMethod() throws Throwable {
AspectTarget aspectTarget = new AspectTarget();
aspectTarget.firstMethod();
}
}
Run Code Online (Sandbox Code Playgroud)
Vmarg:-javaagent:C:.... m2\repository\org\aspectj\aspectjweaver\1.8.1\aspectjweaver-1.8.1.jar
正在测试的类(我有一些问题,因为显然声明它抛出Throwable,这是有道理的,但这个简单的测试没有抛出任何东西.所以我添加了一个虚假的异常使它编译:
package com.test.aspectjdemo.domain;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class AspectTarget {
final Logger logger = LogManager.getLogger();
int x = 1;
public void firstMethod() throws Throwable {
logger.info("Start First Method");
x = secondMethod(x);
logger.info("Exit X is {}", x); …Run Code Online (Sandbox Code Playgroud)