相关疑难解决方法(0)

Spring Boot中多战应用的集成测试

我有一个由多个maven战争项目组成的应用程序.

我有另一个maven项目,使用org.springframework.web.client.RestTemplate调用对手动启动的tomcat部署的多战应用程序运行JUnit集成测试.

但是,我希望我的集成测试项目在运行我的测试之前实际启动我的多战应用程序(一次是整个套件的持续时间)...在spring-boot中!

从我的集成测试项目开始,我希望能够将所有war项目作为spring-boot应用程序一起运行,每个应用程序都有自己的contextPaths(例如localhost:8080/a用于项目'a',localhost:8080/b对于项目'b'等),并且不更改原始的war项目(尚未启动Spring-boot).如果我不能在spring-boot中从我的集成测试项目中运行这些项目而不更改它们那么我至少希望尽可能减少在打包的war文件中使用spring-boot依赖项和配置...尽可能.

我能够让我的集成测试项目依赖于单个war项目,启动它并针对它运行测试......但是我没有成功在spring-boot下在单独的contextPaths下运行两个war项目.

欢迎大家提出意见!

以下是我用过的一些资源:

java junit spring maven spring-boot

7
推荐指数
1
解决办法
2688
查看次数

tomcat7-maven-plugin extraDependency似乎没有被加载

我一直在使用tomcat7-maven-plugin.我想运行我的webapp,它使用嵌入式tomcat连接到PostgreSQL数据库.这是我的POM文件的相关部分:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0-SNAPSHOT</version>
    <executions>
        <execution>
            <id>tomcat-run</id>
            <goals>
                <goal>exec-war-only</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <path>/</path>
                <attachArtifactClassifierType>war</attachArtifactClassifierType>
                <enableNaming>true</enableNaming>
                <extraDependencies>
                    <extraDependency>
                        <groupId>postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                        <version>8.4-701.jdbc4</version>
                    </extraDependency>
                </extraDependencies>
            </configuration>
       </execution>
   </executions>
Run Code Online (Sandbox Code Playgroud)

执行tomcat7:运行失败

Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:236)
... 29 more
Run Code Online (Sandbox Code Playgroud)

依赖本身是正确的(http://repo1.maven.org/maven2/postgresql/postgresql/8.4-701.jdbc4/).

我使用Maven 3.

tomcat maven maven-tomcat-plugin

5
推荐指数
1
解决办法
4319
查看次数

标签 统计

maven ×2

java ×1

junit ×1

maven-tomcat-plugin ×1

spring ×1

spring-boot ×1

tomcat ×1