【Spring】使用SpringTest报错 java.lang.NoSuchMethodError

 

完整报错信息:

"C:\Program Files\Java\jdk1.8.0_301\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar=53174:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\rt.jar;C:\Users\Cloud9\IdeaProjects\EveryThing-Framework\target\test-classes;C:\Users\Cloud9\IdeaProjects\EveryThing-Framework\target\classes;D:\Maven Local Repository\org\apache\curator\curator-framework\5.2.0\curator-framework-5.2.0.jar;D:\Maven Local Repository\org\apache\curator\curator-client\5.2.0\curator-client-5.2.0.jar;D:\Maven Local Repository\org\apache\zookeeper\zookeeper\3.6.3\zookeeper-3.6.3.jar;D:\Maven Local Repository\org\apache\zookeeper\zookeeper-jute\3.6.3\zookeeper-jute-3.6.3.jar;D:\Maven Local Repository\org\apache\yetus\audience-annotations\0.5.0\audience-annotations-0.5.0.jar;D:\Maven Local Repository\io\netty\netty-handler\4.1.63.Final\netty-handler-4.1.63.Final.jar;D:\Maven Local Repository\io\netty\netty-common\4.1.63.Final\netty-common-4.1.63.Final.jar;D:\Maven Local Repository\io\netty\netty-resolver\4.1.63.Final\netty-resolver-4.1.63.Final.jar;D:\Maven Local Repository\io\netty\netty-buffer\4.1.63.Final\netty-buffer-4.1.63.Final.jar;D:\Maven Local Repository\io\netty\netty-transport\4.1.63.Final\netty-transport-4.1.63.Final.jar;D:\Maven Local Repository\io\netty\netty-codec\4.1.63.Final\netty-codec-4.1.63.Final.jar;D:\Maven Local Repository\io\netty\netty-transport-native-epoll\4.1.63.Final\netty-transport-native-epoll-4.1.63.Final.jar;D:\Maven Local Repository\io\netty\netty-transport-native-unix-common\4.1.63.Final\netty-transport-native-unix-common-4.1.63.Final.jar;D:\Maven Local Repository\org\apache\curator\curator-recipes\5.2.0\curator-recipes-5.2.0.jar;D:\Maven Local Repository\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;D:\Maven Local Repository\commons-beanutils\commons-beanutils\1.7.0\commons-beanutils-1.7.0.jar;D:\Maven Local Repository\commons-logging\commons-logging\1.0.3\commons-logging-1.0.3.jar;D:\Maven Local Repository\org\javassist\javassist\3.26.0-GA\javassist-3.26.0-GA.jar;D:\Maven Local Repository\com\alibaba\fastjson\1.2.78\fastjson-1.2.78.jar;D:\Maven Local Repository\javax\servlet\javax.servlet-api\4.0.1\javax.servlet-api-4.0.1.jar;D:\Maven Local Repository\javax\servlet\jstl\1.2\jstl-1.2.jar;D:\Maven Local Repository\javax\servlet\jsp\javax.servlet.jsp-api\2.3.3\javax.servlet.jsp-api-2.3.3.jar;D:\Maven Local Repository\org\reflections\reflections\0.9.11\reflections-0.9.11.jar;D:\Maven Local Repository\com\google\guava\guava\20.0\guava-20.0.jar;D:\Maven Local Repository\mysql\mysql-connector-java\8.0.25\mysql-connector-java-8.0.25.jar;D:\Maven Local Repository\com\google\protobuf\protobuf-java\3.11.4\protobuf-java-3.11.4.jar;D:\Maven Local Repository\io\jsonwebtoken\jjwt\0.9.1\jjwt-0.9.1.jar;D:\Maven Local Repository\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;D:\Maven Local Repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;D:\Maven Local Repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;D:\Maven Local Repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;D:\Maven Local Repository\org\apache\httpcomponents\httpcore\4.4.13\httpcore-4.4.13.jar;D:\Maven Local Repository\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;D:\Maven Local Repository\org\apache\httpcomponents\httpmime\4.5.13\httpmime-4.5.13.jar;D:\Maven Local Repository\junit\junit\4.12\junit-4.12.jar;D:\Maven Local Repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;D:\Maven Local Repository\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;D:\Maven Local Repository\org\slf4j\slf4j-log4j12\1.7.32\slf4j-log4j12-1.7.32.jar;D:\Maven Local Repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;D:\Maven Local Repository\cglib\cglib\2.2.2\cglib-2.2.2.jar;D:\Maven Local Repository\asm\asm\3.3.1\asm-3.3.1.jar;D:\Maven Local Repository\org\apache\poi\poi\5.0.0\poi-5.0.0.jar;D:\Maven Local Repository\org\slf4j\jcl-over-slf4j\1.7.30\jcl-over-slf4j-1.7.30.jar;D:\Maven Local Repository\org\apache\commons\commons-collections4\4.4\commons-collections4-4.4.jar;D:\Maven Local Repository\org\apache\commons\commons-math3\3.6.1\commons-math3-3.6.1.jar;D:\Maven Local Repository\com\zaxxer\SparseBitSet\1.2\SparseBitSet-1.2.jar;D:\Maven Local Repository\org\apache\poi\poi-ooxml\5.0.0\poi-ooxml-5.0.0.jar;D:\Maven Local Repository\org\apache\poi\poi-ooxml-lite\5.0.0\poi-ooxml-lite-5.0.0.jar;D:\Maven Local Repository\org\apache\xmlbeans\xmlbeans\4.0.0\xmlbeans-4.0.0.jar;D:\Maven Local Repository\org\apache\commons\commons-compress\1.20\commons-compress-1.20.jar;D:\Maven Local Repository\com\github\virtuald\curvesapi\1.06\curvesapi-1.06.jar;D:\Maven Local Repository\org\bouncycastle\bcpkix-jdk15on\1.68\bcpkix-jdk15on-1.68.jar;D:\Maven Local Repository\org\bouncycastle\bcprov-jdk15on\1.68\bcprov-jdk15on-1.68.jar;D:\Maven Local Repository\org\apache\santuario\xmlsec\2.2.1\xmlsec-2.2.1.jar;D:\Maven Local Repository\com\fasterxml\woodstox\woodstox-core\5.2.1\woodstox-core-5.2.1.jar;D:\Maven Local Repository\org\codehaus\woodstox\stax2-api\4.2\stax2-api-4.2.jar;D:\Maven Local Repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.2\jakarta.xml.bind-api-2.3.2.jar;D:\Maven Local Repository\jakarta\activation\jakarta.activation-api\1.2.1\jakarta.activation-api-1.2.1.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-all\1.13\batik-all-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-anim\1.13\batik-anim-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-shared-resources\1.13\batik-shared-resources-1.13.jar;D:\Maven Local Repository\xml-apis\xml-apis-ext\1.3.04\xml-apis-ext-1.3.04.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-awt-util\1.13\batik-awt-util-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\xmlgraphics-commons\2.4\xmlgraphics-commons-2.4.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-bridge\1.13\batik-bridge-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-codec\1.13\batik-codec-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-constants\1.13\batik-constants-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-css\1.13\batik-css-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-dom\1.13\batik-dom-1.13.jar;D:\Maven Local Repository\xalan\xalan\2.7.2\xalan-2.7.2.jar;D:\Maven Local Repository\xalan\serializer\2.7.2\serializer-2.7.2.jar;D:\Maven Local Repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-ext\1.13\batik-ext-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-extension\1.13\batik-extension-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-gui-util\1.13\batik-gui-util-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-gvt\1.13\batik-gvt-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-i18n\1.13\batik-i18n-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-parser\1.13\batik-parser-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-rasterizer-ext\1.13\batik-rasterizer-ext-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-rasterizer\1.13\batik-rasterizer-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-script\1.13\batik-script-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-slideshow\1.13\batik-slideshow-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-squiggle-ext\1.13\batik-squiggle-ext-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-squiggle\1.13\batik-squiggle-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-svg-dom\1.13\batik-svg-dom-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-svgbrowser\1.13\batik-svgbrowser-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-svggen\1.13\batik-svggen-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-svgpp\1.13\batik-svgpp-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-svgrasterizer\1.13\batik-svgrasterizer-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-swing\1.13\batik-swing-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-transcoder\1.13\batik-transcoder-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-util\1.13\batik-util-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-ttf2svg\1.13\batik-ttf2svg-1.13.jar;D:\Maven Local Repository\org\apache\xmlgraphics\batik-xml\1.13\batik-xml-1.13.jar;D:\Maven Local Repository\de\rototor\pdfbox\graphics2d\0.30\graphics2d-0.30.jar;D:\Maven Local Repository\org\apache\pdfbox\pdfbox\2.0.22\pdfbox-2.0.22.jar;D:\Maven Local Repository\org\apache\pdfbox\fontbox\2.0.22\fontbox-2.0.22.jar;D:\Maven Local Repository\org\elasticsearch\elasticsearch\7.15.1\elasticsearch-7.15.1.jar;D:\Maven Local Repository\org\elasticsearch\elasticsearch-core\7.15.1\elasticsearch-core-7.15.1.jar;D:\Maven Local Repository\org\elasticsearch\elasticsearch-secure-sm\7.15.1\elasticsearch-secure-sm-7.15.1.jar;D:\Maven Local Repository\org\elasticsearch\elasticsearch-x-content\7.15.1\elasticsearch-x-content-7.15.1.jar;D:\Maven Local Repository\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;D:\Maven Local Repository\com\fasterxml\jackson\dataformat\jackson-dataformat-smile\2.10.4\jackson-dataformat-smile-2.10.4.jar;D:\Maven Local Repository\com\fasterxml\jackson\dataformat\jackson-dataformat-yaml\2.10.4\jackson-dataformat-yaml-2.10.4.jar;D:\Maven Local Repository\com\fasterxml\jackson\dataformat\jackson-dataformat-cbor\2.10.4\jackson-dataformat-cbor-2.10.4.jar;D:\Maven Local Repository\org\elasticsearch\elasticsearch-geo\7.15.1\elasticsearch-geo-7.15.1.jar;D:\Maven Local Repository\org\apache\lucene\lucene-core\8.9.0\lucene-core-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-analyzers-common\8.9.0\lucene-analyzers-common-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-backward-codecs\8.9.0\lucene-backward-codecs-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-grouping\8.9.0\lucene-grouping-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-highlighter\8.9.0\lucene-highlighter-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-join\8.9.0\lucene-join-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-memory\8.9.0\lucene-memory-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-misc\8.9.0\lucene-misc-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-queries\8.9.0\lucene-queries-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-queryparser\8.9.0\lucene-queryparser-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-sandbox\8.9.0\lucene-sandbox-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-spatial-extras\8.9.0\lucene-spatial-extras-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-spatial3d\8.9.0\lucene-spatial3d-8.9.0.jar;D:\Maven Local Repository\org\apache\lucene\lucene-suggest\8.9.0\lucene-suggest-8.9.0.jar;D:\Maven Local Repository\org\elasticsearch\elasticsearch-cli\7.15.1\elasticsearch-cli-7.15.1.jar;D:\Maven Local Repository\net\sf\jopt-simple\jopt-simple\5.0.2\jopt-simple-5.0.2.jar;D:\Maven Local Repository\com\carrotsearch\hppc\0.8.1\hppc-0.8.1.jar;D:\Maven Local Repository\org\lz4\lz4-java\1.8.0\lz4-java-1.8.0.jar;D:\Maven Local Repository\joda-time\joda-time\2.10.10\joda-time-2.10.10.jar;D:\Maven Local Repository\com\tdunning\t-digest\3.2\t-digest-3.2.jar;D:\Maven Local Repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;D:\Maven Local Repository\org\apache\logging\log4j\log4j-api\2.11.1\log4j-api-2.11.1.jar;D:\Maven Local Repository\org\elasticsearch\jna\5.7.0-1\jna-5.7.0-1.jar;D:\Maven Local Repository\org\elasticsearch\elasticsearch-plugin-classloader\7.15.1\elasticsearch-plugin-classloader-7.15.1.jar;D:\Maven Local Repository\org\apache\activemq\activemq-all\5.16.3\activemq-all-5.16.3.jar;D:\Maven Local Repository\org\springframework\spring-core\5.2.18.RELEASE\spring-core-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-jcl\5.2.18.RELEASE\spring-jcl-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-web\5.2.18.RELEASE\spring-web-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-beans\5.2.18.RELEASE\spring-beans-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-oxm\5.2.18.RELEASE\spring-oxm-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-tx\5.2.18.RELEASE\spring-tx-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-jdbc\5.2.18.RELEASE\spring-jdbc-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-webmvc\5.2.18.RELEASE\spring-webmvc-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-context\5.2.18.RELEASE\spring-context-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-expression\5.2.18.RELEASE\spring-expression-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-aop\5.2.18.RELEASE\spring-aop-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-context-support\5.2.18.RELEASE\spring-context-support-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-test\5.2.18.RELEASE\spring-test-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-jms\5.2.18.RELEASE\spring-jms-5.2.18.RELEASE.jar;D:\Maven Local Repository\org\springframework\spring-messaging\5.2.18.RELEASE\spring-messaging-5.2.18.RELEASE.jar;D:\Maven Local Repository\javax\jms\javax.jms-api\2.0.1\javax.jms-api-2.0.1.jar;D:\Maven Local Repository\org\apache\xbean\xbean-spring\3.7\xbean-spring-3.7.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 cn.cloud9.test.activemq.springactivemq.SpringActiveMqConsumer,springActiveMqConsume
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/Maven%20Local%20Repository/org/slf4j/slf4j-log4j12/1.7.32/slf4j-log4j12-1.7.32.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/Maven%20Local%20Repository/org/apache/activemq/activemq-all/5.16.3/activemq-all-5.16.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
[2021-11-02 08:14:25 上午]:DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:139)SpringJUnit4ClassRunner constructor called with [class cn.cloud9.test.activemq.springactivemq.SpringActiveMqConsumer]
[2021-11-02 08:14:25 上午]:DEBUG org.springframework.test.context.BootstrapUtils.createCacheAwareContextLoaderDelegate(BootstrapUtils.java:96)Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
[2021-11-02 08:14:25 上午]:DEBUG org.springframework.test.context.BootstrapUtils.createBootstrapContext(BootstrapUtils.java:79)Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
[2021-11-02 08:14:25 上午]:DEBUG org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper(BootstrapUtils.java:132)Instantiating TestContextBootstrapper for test class [cn.cloud9.test.activemq.springactivemq.SpringActiveMqConsumer] from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]

java.lang.NoSuchMethodError: org.springframework.util.Assert.notNull(Ljava/lang/Object;Ljava/util/function/Supplier;)V

    at org.springframework.test.context.support.ContextLoaderUtils.resolveContextConfigurationAttributes(ContextLoaderUtils.java:244)
    at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:295)
    at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildTestContext(AbstractTestContextBootstrapper.java:108)
    at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:137)
    at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:122)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:151)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:142)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)


Process finished with exit code -1

 

问题出现在使用SpringTest组件的注解 @Runwith上面

package cn.cloud9.test.activemq.springactivemq;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class) // junit与spring整合
@ContextConfiguration(locations = {"classpath:ActiveMQ-Consumer.xml"}) // 加载spring配置文件
public class SpringActiveMqConsumer {

    @Test
    public void springActiveMqConsume() throws Exception {
        // ApplicationContext ac = new ClassPathXmlApplicationContext("ActiveMQ-Consumer.xml");
        System.in.read();
    }
}

 

 

所有Spring组件配置版本:

<spring-version>5.2.18.RELEASE</spring-version>

Junit测试版本:

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

 

解决办法是给SpringTest单独设置版本:

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <!--<version>${spring-version}</version>-->
            <version>4.1.6.RELEASE</version>
        </dependency>

参考博客:

https://blog.csdn.net/wuzongpo/article/details/52036096

 

问题原因尚未找到。。。。

 

SpringBoot报错:

"C:\Program Files\Java\jdk1.8.0_301\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar=64350:C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\Cloud9\.m2\repository\org\junit\platform\junit-platform-launcher\1.7.2\junit-platform-launcher-1.7.2.jar;C:\Users\Cloud9\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\Cloud9\.m2\repository\org\junit\platform\junit-platform-engine\1.7.2\junit-platform-engine-1.7.2.jar;C:\Users\Cloud9\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Cloud9\.m2\repository\org\junit\platform\junit-platform-commons\1.7.2\junit-platform-commons-1.7.2.jar;C:\Users\Cloud9\.m2\repository\org\junit\vintage\junit-vintage-engine\5.7.2\junit-vintage-engine-5.7.2.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_301\jre\lib\rt.jar;C:\Users\Cloud9\IdeaProjects\EveryThing-Interface\target\test-classes;C:\Users\Cloud9\IdeaProjects\EveryThing-Interface\target\classes;D:\Maven Local Repository\org\springframework\boot\spring-boot-starter-web\2.5.6\spring-boot-starter-web-2.5.6.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-starter\2.5.6\spring-boot-starter-2.5.6.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-starter-logging\2.5.6\spring-boot-starter-logging-2.5.6.jar;D:\Maven Local Repository\ch\qos\logback\logback-classic\1.2.6\logback-classic-1.2.6.jar;D:\Maven Local Repository\ch\qos\logback\logback-core\1.2.6\logback-core-1.2.6.jar;D:\Maven Local Repository\org\apache\logging\log4j\log4j-to-slf4j\2.14.1\log4j-to-slf4j-2.14.1.jar;D:\Maven Local Repository\org\apache\logging\log4j\log4j-api\2.14.1\log4j-api-2.14.1.jar;D:\Maven Local Repository\org\slf4j\jul-to-slf4j\1.7.32\jul-to-slf4j-1.7.32.jar;D:\Maven Local Repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\Maven Local Repository\org\yaml\snakeyaml\1.28\snakeyaml-1.28.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-starter-json\2.5.6\spring-boot-starter-json-2.5.6.jar;D:\Maven Local Repository\com\fasterxml\jackson\core\jackson-databind\2.12.5\jackson-databind-2.12.5.jar;D:\Maven Local Repository\com\fasterxml\jackson\core\jackson-annotations\2.12.5\jackson-annotations-2.12.5.jar;D:\Maven Local Repository\com\fasterxml\jackson\core\jackson-core\2.12.5\jackson-core-2.12.5.jar;D:\Maven Local Repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.12.5\jackson-datatype-jdk8-2.12.5.jar;D:\Maven Local Repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.12.5\jackson-datatype-jsr310-2.12.5.jar;D:\Maven Local Repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.12.5\jackson-module-parameter-names-2.12.5.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-starter-tomcat\2.5.6\spring-boot-starter-tomcat-2.5.6.jar;D:\Maven Local Repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.54\tomcat-embed-core-9.0.54.jar;D:\Maven Local Repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.54\tomcat-embed-el-9.0.54.jar;D:\Maven Local Repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.54\tomcat-embed-websocket-9.0.54.jar;D:\Maven Local Repository\org\springframework\spring-web\5.3.12\spring-web-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-beans\5.3.12\spring-beans-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-webmvc\5.3.12\spring-webmvc-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-aop\5.3.12\spring-aop-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-context\5.3.12\spring-context-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-expression\5.3.12\spring-expression-5.3.12.jar;D:\Maven Local Repository\org\springframework\experimental\spring-native\0.10.4\spring-native-0.10.4.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-starter-activemq\2.5.6\spring-boot-starter-activemq-2.5.6.jar;D:\Maven Local Repository\org\springframework\spring-jms\5.3.12\spring-jms-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-messaging\5.3.12\spring-messaging-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-tx\5.3.12\spring-tx-5.3.12.jar;D:\Maven Local Repository\org\apache\activemq\activemq-broker\5.16.3\activemq-broker-5.16.3.jar;D:\Maven Local Repository\org\apache\activemq\activemq-client\5.16.3\activemq-client-5.16.3.jar;D:\Maven Local Repository\org\fusesource\hawtbuf\hawtbuf\1.11\hawtbuf-1.11.jar;D:\Maven Local Repository\org\apache\activemq\activemq-openwire-legacy\5.16.3\activemq-openwire-legacy-5.16.3.jar;D:\Maven Local Repository\jakarta\jms\jakarta.jms-api\2.0.3\jakarta.jms-api-2.0.3.jar;D:\Maven Local Repository\jakarta\management\j2ee\jakarta.management.j2ee-api\1.1.4\jakarta.management.j2ee-api-1.1.4.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-devtools\2.5.6\spring-boot-devtools-2.5.6.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot\2.5.6\spring-boot-2.5.6.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-autoconfigure\2.5.6\spring-boot-autoconfigure-2.5.6.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-configuration-processor\2.5.6\spring-boot-configuration-processor-2.5.6.jar;D:\Maven Local Repository\org\projectlombok\lombok\1.18.22\lombok-1.18.22.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-starter-test\2.5.6\spring-boot-starter-test-2.5.6.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-test\2.5.6\spring-boot-test-2.5.6.jar;D:\Maven Local Repository\org\springframework\boot\spring-boot-test-autoconfigure\2.5.6\spring-boot-test-autoconfigure-2.5.6.jar;D:\Maven Local Repository\com\jayway\jsonpath\json-path\2.5.0\json-path-2.5.0.jar;D:\Maven Local Repository\net\minidev\json-smart\2.4.7\json-smart-2.4.7.jar;D:\Maven Local Repository\net\minidev\accessors-smart\2.4.7\accessors-smart-2.4.7.jar;D:\Maven Local Repository\org\ow2\asm\asm\9.1\asm-9.1.jar;D:\Maven Local Repository\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;D:\Maven Local Repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;D:\Maven Local Repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;D:\Maven Local Repository\org\assertj\assertj-core\3.19.0\assertj-core-3.19.0.jar;D:\Maven Local Repository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;D:\Maven Local Repository\org\junit\jupiter\junit-jupiter\5.7.2\junit-jupiter-5.7.2.jar;D:\Maven Local Repository\org\junit\jupiter\junit-jupiter-api\5.7.2\junit-jupiter-api-5.7.2.jar;D:\Maven Local Repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;D:\Maven Local Repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;D:\Maven Local Repository\org\junit\platform\junit-platform-commons\1.7.2\junit-platform-commons-1.7.2.jar;D:\Maven Local Repository\org\junit\jupiter\junit-jupiter-params\5.7.2\junit-jupiter-params-5.7.2.jar;D:\Maven Local Repository\org\junit\jupiter\junit-jupiter-engine\5.7.2\junit-jupiter-engine-5.7.2.jar;D:\Maven Local Repository\org\junit\platform\junit-platform-engine\1.7.2\junit-platform-engine-1.7.2.jar;D:\Maven Local Repository\org\mockito\mockito-core\3.9.0\mockito-core-3.9.0.jar;D:\Maven Local Repository\net\bytebuddy\byte-buddy\1.10.22\byte-buddy-1.10.22.jar;D:\Maven Local Repository\net\bytebuddy\byte-buddy-agent\1.10.22\byte-buddy-agent-1.10.22.jar;D:\Maven Local Repository\org\objenesis\objenesis\3.2\objenesis-3.2.jar;D:\Maven Local Repository\org\mockito\mockito-junit-jupiter\3.9.0\mockito-junit-jupiter-3.9.0.jar;D:\Maven Local Repository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;D:\Maven Local Repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;D:\Maven Local Repository\org\springframework\spring-core\5.3.12\spring-core-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-jcl\5.3.12\spring-jcl-5.3.12.jar;D:\Maven Local Repository\org\springframework\spring-test\5.3.12\spring-test-5.3.12.jar;D:\Maven Local Repository\org\xmlunit\xmlunit-core\2.8.3\xmlunit-core-2.8.3.jar;D:\Maven Local Repository\junit\junit\4.13.2\junit-4.13.2.jar;D:\Maven Local Repository\org\hamcrest\hamcrest-core\2.2\hamcrest-core-2.2.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 cn.cloud9.everythinginterface.activemq.ActiveMqTest,ptpSender
十一月 04, 2021 7:43:30 上午 org.junit.vintage.engine.descriptor.RunnerTestDescriptor warnAboutUnfilterableRunner
警告: Runner org.junit.internal.runners.ErrorReportingRunner (used on class cn.cloud9.everythinginterface.activemq.ActiveMqTest) does not support filtering and will therefore be run completely.

org.junit.runners.model.InvalidTestClassError: Invalid test class 'cn.cloud9.everythinginterface.activemq.ActiveMqTest':
  1. No runnable methods

    at org.junit.runners.ParentRunner.validate(ParentRunner.java:525)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:92)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:74)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:137)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder.buildRunner(DefensiveAllDefaultPossibilitiesBuilder.java:114)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
    at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.runnerForClass(DefensiveAllDefaultPossibilitiesBuilder.java:57)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
    at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolveTestClass(ClassSelectorResolver.java:66)
    at org.junit.vintage.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:47)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:134)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.access$100(EngineDiscoveryRequestResolution.java:57)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution$DefaultContext.resolve(EngineDiscoveryRequestResolution.java:224)
    at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolveParentAndAddFilter(MethodSelectorResolver.java:55)
    at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:39)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:146)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:185)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:125)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:91)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:82)
    at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)
    at org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:44)
    at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:63)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:103)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:85)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:92)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

07:43:30.883 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
07:43:30.893 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
07:43:30.918 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [cn.cloud9.everythinginterface.activemq.ActiveMqTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
07:43:30.932 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [cn.cloud9.everythinginterface.activemq.ActiveMqTest], using SpringBootContextLoader
07:43:30.933 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [cn.cloud9.everythinginterface.activemq.ActiveMqTest]: class path resource [cn/cloud9/everythinginterface/activemq/ActiveMqTest-context.xml] does not exist
07:43:30.933 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [cn.cloud9.everythinginterface.activemq.ActiveMqTest]: class path resource [cn/cloud9/everythinginterface/activemq/ActiveMqTestContext.groovy] does not exist
07:43:30.933 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [cn.cloud9.everythinginterface.activemq.ActiveMqTest]: no resource found for suffixes {-context.xml, Context.groovy}.
07:43:30.973 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [cn.cloud9.everythinginterface.activemq.ActiveMqTest]
07:43:31.099 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [cn.cloud9.everythinginterface.activemq.ActiveMqTest]: using defaults.
07:43:31.099 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
07:43:31.114 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@7fb4f2a9, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@4dc27487, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@6a4f1a55, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@7dfd3c81, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@2584b82d, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7bbc8656, org.springframework.test.context.transaction.TransactionalTestExecutionListener@6933b6c6, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@7d3e8655, org.springframework.test.context.event.EventPublishingTestExecutionListener@7dfb0c0f, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@626abbd0, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@169bb4dd, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@1f9e9475, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@3aa078fd, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@d23e042, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@46d59067]
07:43:31.119 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@7dc19a70 testClass = ActiveMqTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@508dec2b testClass = ActiveMqTest, locations = '{}', classes = '{class cn.cloud9.everythinginterface.EveryThingInterfaceApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@5fbe4146, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7530ad9c, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@757277dc, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@37271612, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@2898ac89, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@2d6d8735], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
07:43:31.154 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.6)

2021-11-04 07:43:31.465  INFO 121552 --- [           main] c.c.e.activemq.ActiveMqTest              : Starting ActiveMqTest using Java 1.8.0_301 on DESKTOP-P46A09B with PID 121552 (started by Cloud9 in C:\Users\Cloud9\IdeaProjects\EveryThing-Interface)
2021-11-04 07:43:31.465  INFO 121552 --- [           main] c.c.e.activemq.ActiveMqTest              : No active profile set, falling back to default profiles: default
2021-11-04 07:43:33.000  INFO 121552 --- [           main] c.c.e.activemq.ActiveMqTest              : Started ActiveMqTest in 1.83 seconds (JVM running for 2.669)

Process finished with exit code -1

原因是使用的这个Test

应该使用下面的这个Test注解

package cn.cloud9.everythinginterface.activemq;


import cn.cloud9.everythinginterface.EveryThingInterfaceApplication;
import org.junit.jupiter.api.Test;
// import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/*** 演示SpringBoot与ActiveMQ整合- 消息生产者 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = EveryThingInterfaceApplication.class)
public class ActiveMqTest {
    //JmsMessagingTemplate: 用于工具类发送消息
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Test
    public void ptpSender(){
        /**
         * 参数一:队列的名称或主题名称 * 参数二:消息内容
         */
        jmsMessagingTemplate.convertAndSend("springboot_queue","spring boot message");
    }

}

 

但是并不影响程序执行???,JMS的消息还是发送了

 

posted @ 2021-11-02 08:20  emdzz  阅读(646)  评论(0编辑  收藏  举报