工程中使用spring AOP 处理org.junit.Test注解;编译 本地运行没问题;打成jar包在服务器上运行报错

package com.unionpay.pipbat.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class TestAspect {
    private final static Logger logger = LoggerFactory.getLogger(TestAspect.class);


    @Pointcut("@annotation(org.junit.Test)")
    private void initProc() {

    }

    @Before("initProc()")
    public void beforeMethod(JoinPoint joinPoint) {
        logger.info("测试程序初始化开始");
        //初始化客户端证书
        //SecureMangerContainer.getInstance().init();

        logger.info("测试程序初始化结束");
    }

}

异常栈:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error Type referred to is not an annotation type: org$junit$Test
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:584)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:392)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
        at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109)
        at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92)
        at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:253)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1091)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1064)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:487)
        ... 22 common frames omitted
Caused by: java.lang.IllegalArgumentException: error Type referred to is not an annotation type: org$junit$Test
        at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:319)
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:227)
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.obtainPointcutExpression(AspectJExpressionPointcut.java:198)
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:177)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:225)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:288)
        at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:320)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:126)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:95)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:76)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:349)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:301)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
 

 

 

显示spring在创建TestAspect 的bean实例的时候找不到一个叫org.junit.Test的注解

至于为什么 还有待研究

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Files contained in junit4-4.8.2.jar: LICENSE.txt META-INF/MANIFEST.MF junit.extensions.ActiveTestSuite.class junit.extensions.RepeatedTest.class junit.extensions.TestDecorator.class junit.extensions.TestSetup.class junit.extensions.package-info.class junit.framework.Assert.class junit.framework.AssertionFailedError.class junit.framework.ComparisonCompactor.class junit.framework.ComparisonFailure.class junit.framework.JUnit4TestAdapter.class junit.framework.JUnit4TestAdapterCache.class junit.framework.JUnit4TestCaseFacade.class junit.framework.Protectable.class junit.framework.Test.class junit.framework.TestCase.class junit.framework.TestFailure.class junit.framework.TestListener.class junit.framework.TestResult.class junit.framework.TestSuite.class junit.framework.package-info.class junit.runner.BaseTestRunner.class junit.runner.TestRunListener.class junit.runner.Version.class junit.runner.package-info.class junit.textui.ResultPrinter.class junit.textui.TestRunner.class junit.textui.package-info.class org.hamcrest.BaseDescription.class org.hamcrest.BaseMatcher.class org.hamcrest.CoreMatchers.class org.hamcrest.Description.class org.hamcrest.Factory.class org.hamcrest.Matcher.class org.hamcrest.SelfDescribing.class org.hamcrest.StringDescription.class org.hamcrest.core.AllOf.class org.hamcrest.core.AnyOf.class org.hamcrest.core.DescribedAs.class org.hamcrest.core.Is.class org.hamcrest.core.IsAnything.class org.hamcrest.core.IsEqual.class org.hamcrest.core.IsInstanceOf.class org.hamcrest.core.IsNot.class org.hamcrest.core.IsNull.class org.hamcrest.core.IsSame.class org.hamcrest.internal.ArrayIterator.class org.hamcrest.internal.SelfDescribingValue.class org.hamcrest.internal.SelfDescribingValueIterator.class org.junit.After.class org.junit.AfterClass.class org.junit.Assert.class org.junit.Assume.class org.junit.Before.class org.junit.BeforeClass.class org.junit.ComparisonFailure.class org.junit.Ignore.class org.junit.Rule.class org.junit.Test.class org.junit.experimental.ParallelComputer.class org.junit.experimental.categories.Categories.class org.junit.experimental.categories.Category.class org.junit.experimental.max.CouldNotReadCoreException.class org.junit.experimental.max.MaxCore.class org.junit.experimental.max.MaxHistory.class org.junit.experimental.results.FailureList.class org.junit.experimental.results.PrintableResult.class org.junit.experimental.results.ResultMatchers.class org.junit.experimental.runners.Enclosed.class org.junit.experimental.theories.DataPoint.class org.junit.experimental.theories.DataPoints.class org.junit.experimental.theories.ParameterSignature.class org.junit.experimental.theories.ParameterSupplier.class org.junit.experimental.theories.ParametersSuppliedBy.class org.junit.experimental.theories.PotentialAssignment.class org.junit.experimental.theories.Theories.class org.junit.experimental.theories.Theory.class org.junit.experimental.theories.internal.AllMembersSupplier.class org.junit.experimental.theories.internal.Assignments.class org.junit.experimental.theories.internal.ParameterizedAssertionError.class org.junit.experimental.theories.suppliers.TestedOn.class org.junit.experimental.theories.suppliers.TestedOnSupplier.class org.junit.internal.ArrayComparisonFailure.class org.junit.internal.AssumptionViolatedException.class org.junit.internal.ComparisonCriteria.class org.junit.internal.ExactComparisonCriteria.class org.junit.internal.InexactComparisonCriteria.class org.junit.internal.JUnitSystem.class org.junit.internal.RealSystem.class org.junit.internal.TextListener.class org.junit.internal.builders.AllDefaultPossibilitiesBuilder.class org.junit.internal.builders.AnnotatedBuilder.class org.junit.internal.builders.IgnoredBuilder.class org.junit.internal.builders.IgnoredClassRunner.class org.junit.internal.builders.JUnit3Builder.class org.junit.internal.builders.JUnit4Builder.class org.junit.internal.builders.NullBuilder.class org.junit.internal.builders.SuiteMethodBuilder.class org.junit.internal.matchers.CombinableMatcher.class org.junit.internal.matchers.Each.class org.junit.internal.matchers.IsCollectionContaining.class org.junit.internal.matchers.StringContains.class org.junit.internal.matchers.SubstringMatcher.class org.junit.internal.matchers.TypeSafeMatcher.class org.junit.internal.requests.ClassRequest.class org.junit.internal.requests.FilterRequest.class org.junit.internal.requests.SortingRequest.class org.junit.internal.requests.package-info.class org.junit.internal.runners.ClassRoadie.class org.junit.internal.runners.ErrorReportingRunner.class org.junit.internal.runners.FailedBefore.class org.junit.internal.runners.InitializationError.class org.junit.internal.runners.JUnit38ClassRunner.class org.junit.internal.runners.JUnit4ClassRunner.class org.junit.internal.runners.MethodRoadie.class org.junit.internal.runners.MethodValidator.class org.junit.internal.runners.SuiteMethod.class org.junit.internal.runners.TestClass.class org.junit.internal.runners.TestMethod.class org.junit.internal.runners.model.EachTestNotifier.class org.junit.internal.runners.model.MultipleFailureException.class org.junit.internal.runners.model.ReflectiveCallable.class org.junit.internal.runners.package-info.class org.junit.internal.runners.statements.ExpectException.class org.junit.internal.runners.statements.Fail.class org.junit.internal.runners.statements.FailOnTimeout.class org.junit.internal.runners.statements.InvokeMethod.class org.junit.internal.runners.statements.RunAfters.class org.junit.internal.runners.statements.RunBefores.class org.junit.matchers.JUnitMatchers.class org.junit.matchers.package-info.class org.junit.package-info.class org.junit.rules.ErrorCollector.class org.junit.rules.ExpectedException.class org.junit.rules.ExternalResource.class org.junit.rules.MethodRule.class org.junit.rules.TemporaryFolder.class org.junit.rules.TestName.class org.junit.rules.TestWatchman.class org.junit.rules.Timeout.class org.junit.rules.Verifier.class org.junit.runner.Computer.class org.junit.runner.Describable.class org.junit.runner.Description.class org.junit.runner.JUnitCore.class org.junit.runner.Request.class org.junit.runner.Result.class org.junit.runner.RunWith.class org.junit.runner.Runner.class org.junit.runner.manipulation.Filter.class org.junit.runner.manipulation.Filterable.class org.junit.runner.manipulation.NoTestsRemainException.class org.junit.runner.manipulation.Sortable.class org.junit.runner.manipulation.Sorter.class org.junit.runner.manipulation.package-info.class org.junit.runner.notification.Failure.class org.junit.runner.notification.RunListener.class org.junit.runner.notification.RunNotifier.class org.junit.runner.notification.StoppedByUserException.class org.junit.runner.notification.package-info.class org.junit.runner.package-info.class org.junit.runners.AllTests.class org.junit.runners.BlockJUnit4ClassRunner.class org.junit.runners.JUnit4.class org.junit.runners.Parameterized.class org.junit.runners.ParentRunner.class org.junit.runners.Suite.class org.junit.runners.model.FrameworkField.class org.junit.runners.model.FrameworkMember.class org.junit.runners.model.FrameworkMethod.class org.junit.runners.model.InitializationError.class org.junit.runners.model.RunnerBuilder.class org.junit.runners.model.RunnerScheduler.class org.junit.runners.model.Statement.class org.junit.runners.model.TestClass.class org.junit.runners.package-info.class org/hamcrest/core/package.html org/hamcrest/package.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值