Java 为Maven预集成测试阶段启动多个Spring Boot应用程序

Java 为Maven预集成测试阶段启动多个Spring Boot应用程序,java,maven,spring-boot,integration-testing,lifecycle,Java,Maven,Spring Boot,Integration Testing,Lifecycle,我有两个spring启动应用程序,一个包含在src/test中,另一个包含在src/main中 我正在使用Maven verify运行SOAP集成测试。我已经成功启动了我的主应用程序,但还想启动我的测试应用程序预集成。我想在我的测试应用程序上运行测试,然后我需要主应用程序也打开,以便它可以连接到SOAP端点 当我运行mvn verify时,它会在预集成中启动我的主应用程序,然后只运行我的集成测试。是否可以启动另一个应用程序?如果是,如何将其配置到maven springboot插件中 [INFO

我有两个spring启动应用程序,一个包含在src/test中,另一个包含在src/main中

我正在使用Maven verify运行SOAP集成测试。我已经成功启动了我的主应用程序,但还想启动我的测试应用程序预集成。我想在我的测试应用程序上运行测试,然后我需要主应用程序也打开,以便它可以连接到SOAP端点

当我运行mvn verify时,它会在预集成中启动我的主应用程序,然后只运行我的集成测试。是否可以启动另一个应用程序?如果是,如何将其配置到maven springboot插件中

[INFO] --- spring-boot-maven-plugin:2.1.0.RELEASE:start (pre-integration-test) @ billing_mediator ---

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

2019-08-21 09:20:41.577  INFO 53762 --- [ling.App.main()] com.nulogix.billing.App                  : Starting App on Alexs-MacBook-Pro.local with PID 53762 (/Users/Alex/Documents/billing/billing_mediator/target/classes started by asluborski in /Users/asluborski/Documents/billing/billing_mediator)
2019-08-21 09:20:41.582 DEBUG 53762 --- [ling.App.main()] com.nulogix.billing.App                  : Running with Spring Boot v2.1.0.RELEASE, Spring v5.1.2.RELEASE
2019-08-21 09:20:41.585  INFO 53762 --- [ling.App.main()] com.nulogix.billing.App                  : No active profile set, falling back to default profiles: default
2019-08-21 09:20:42.541  INFO 53762 --- [ling.App.main()] trationDelegate$BeanPostProcessorChecker : Bean 'webServiceConfig' of type [com.nulogix.billing.ws.endpoint.WebServiceConfig$$EnhancerBySpringCGLIB$$ad324219] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-21 09:20:42.544  INFO 53762 --- [ling.App.main()] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$668ea787] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-21 09:20:42.593  INFO 53762 --- [ling.App.main()] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2019-08-21 09:20:43.099  INFO 53762 --- [ling.App.main()] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 28443 (https)
2019-08-21 09:20:43.128  INFO 53762 --- [ling.App.main()] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-08-21 09:20:43.129  INFO 53762 --- [ling.App.main()] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.12
2019-08-21 09:20:43.144  INFO 53762 --- [ling.App.main()] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/asluborski/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2019-08-21 09:20:43.258  INFO 53762 --- [ling.App.main()] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-08-21 09:20:43.258  INFO 53762 --- [ling.App.main()] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1625 ms
2019-08-21 09:20:43.300  INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.ServletRegistrationBean  : Servlet messageDispatcherServlet mapped to [/nulogix/ws/*]
2019-08-21 09:20:43.302  INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2019-08-21 09:20:43.307  INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-08-21 09:20:43.308  INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-08-21 09:20:43.308  INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'formContentFilter' to: [/*]
2019-08-21 09:20:43.308  INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-08-21 09:20:43.350 DEBUG 53762 --- [ling.App.main()] c.n.b.service.PredictionEngineService    : billing.engine.address=127.0.0.1
2019-08-21 09:20:43.351 DEBUG 53762 --- [ling.App.main()] c.n.b.service.PredictionEngineService    : billing.engine.port=9119
2019-08-21 09:20:43.351 DEBUG 53762 --- [ling.App.main()] c.n.b.service.PredictionEngineService    : Using http://127.0.0.1:9119
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/Users/asluborski/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.11/jaxb-impl-2.2.11.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-08-21 09:20:43.847 DEBUG 53762 --- [ling.App.main()] c.n.billing.ws.endpoint.AnalyzeEndPoint  : billing.engine.api.version=0.97
2019-08-21 09:20:43.847 DEBUG 53762 --- [ling.App.main()] c.n.billing.ws.endpoint.AnalyzeEndPoint  : billing.engine.core.version=0.97
2019-08-21 09:20:43.848 DEBUG 53762 --- [ling.App.main()] c.n.billing.ws.endpoint.AnalyzeEndPoint  : billing.engine.core.name=Nulogix_Patient_Responsibility
2019-08-21 09:20:43.851 DEBUG 53762 --- [ling.App.main()] c.n.b.ws.endpoint.GetVersionEndPoint     : billing.engine.api.version=0.97
2019-08-21 09:20:44.099  INFO 53762 --- [ling.App.main()] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-21 09:20:45.055  INFO 53762 --- [ling.App.main()] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 28443 (https) with context path ''
2019-08-21 09:20:45.060  INFO 53762 --- [ling.App.main()] com.nulogix.billing.App                  : Started App in 4.044 seconds (JVM running for 13.722)
[INFO] 
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default) @ billing_mediator ---
编辑:

因此,我编辑了我的POM并添加了这样的多次执行(不确定这是否正确,找不到任何关于如何为spring boot maven插件执行此操作的文档)

不知道为什么它会给我这个错误,因为它是正确的类路径,并且该类存在于src/test/java下

编辑:

我把它添加到插件的配置中

<plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
             <includePom>true</includePom>      
             <additionalClasspathElements>
            <additionalClasspathElement>${basedir}/target/test-classes</additionalClasspathElement>
        </additionalClasspathElements>    
        </configuration>  

org.springframework.boot
springbootmaven插件
真的
${basedir}/target/test类
但我也犯了同样的错误

添加classpathscope也无法修复:

<execution>
                    <id>pre-integration-test2</id>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>

               <mainClass>com.nulogix.billing.mockserver.MockServerApp</mainClass> 
              <classpathScope>test</classpathScope>
                    </configuration>                                      
                </execution>

预集成测试2
开始
com.nulogix.billing.mockserver.MockServerApp
测试

请澄清预期的订购情况好吗?@ArnaudClaudel我希望它在预集成前启动我的测试服务器(9119上的MockServerApp)并启动我的主应用服务器(28433上的应用),然后运行集成测试,然后在集成后关闭这两个应用谢谢,我认为您可以通过定义几个spring引导插件的执行来实现这一点,以启动和停止每个应用程序。查看如何执行此操作。我写不出完整的答案now@ArnaudClaudel因此,我试图从您链接的问题的答案中找到解决方案。这是一个不同的插件,但我试图设置单独的执行。它似乎在技术上可以工作,因为它试图加载我的应用程序,但它给了我一个类未发现异常。我用更多的信息编辑了我的问题。
<plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
             <includePom>true</includePom>      
             <additionalClasspathElements>
            <additionalClasspathElement>${basedir}/target/test-classes</additionalClasspathElement>
        </additionalClasspathElements>    
        </configuration>  
<execution>
                    <id>pre-integration-test2</id>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>

               <mainClass>com.nulogix.billing.mockserver.MockServerApp</mainClass> 
              <classpathScope>test</classpathScope>
                    </configuration>                                      
                </execution>