Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 并行运行tomcat插件运行mvn安装_Java_Maven_Configuration_Embedded Tomcat 7 - Fatal编程技术网

Java 并行运行tomcat插件运行mvn安装

Java 并行运行tomcat插件运行mvn安装,java,maven,configuration,embedded-tomcat-7,Java,Maven,Configuration,Embedded Tomcat 7,在这个项目中,有一些单元测试和前端html测试需要运行webserver。 为了mvn安装顺利通过,我需要这两种测试都顺利通过。 我使用嵌入式tomcat服务器,它是通过maven的tomcat插件启动的: mvn tomcat7:run 因此,我启动了tomcat(它是我前端html测试所需要的), 然后尝试在命令行中启动:mvn install,但出现以下错误: D:\PROJECTS\SpringMvcExample>mvn install ERROR: transport err

在这个项目中,有一些单元测试和前端html测试需要运行webserver。 为了
mvn安装
顺利通过,我需要这两种测试都顺利通过。 我使用嵌入式tomcat服务器,它是通过maven的tomcat插件启动的:

mvn tomcat7:run
因此,我启动了tomcat(它是我前端html测试所需要的), 然后尝试在命令行中启动:
mvn install
,但出现以下错误:

D:\PROJECTS\SpringMvcExample>mvn install
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:741]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
同时,当tomcat启动时,我可以通过Intellij Idea插件for maven运行
mvn install
,它工作正常,没有任何错误

我的问题是如何配置以便在命令行中启动maven

这是maven多模块项目,下面是web模块的pom.xml:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 

http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.savdev</groupId>
    <artifactId>SpringMvcExample</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>SpringMvcExample Webapp</name>

<properties>
    <spring.version>3.2.4.RELEASE</spring.version>
    <selenium.version>2.37.1</selenium.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <!--modules dependency start-->
    <dependency>
        <groupId>com.savdev</groupId>
        <artifactId>model</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.savdev</groupId>
        <artifactId>service</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <!--modules dependency end-->

    <!--web dependency start-->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency>
    <!--web dependency end-->

    <!--tests dependency-->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>org.mockito</groupId>-->
        <!--<artifactId>mockito-all</artifactId>-->
        <!--<version>1.9.5</version>-->
        <!--<scope>test</scope>-->
    <!--</dependency>-->
    <dependency>
        <groupId>net.sourceforge.jwebunit</groupId>
        <artifactId>jwebunit-core</artifactId>
        <version>3.1</version>
        <scope>test</scope>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>net.sourceforge.jwebunit</groupId>-->
        <!--<artifactId>jwebunit-htmlunit-plugin</artifactId>-->
        <!--<version>3.1</version>-->
    <!--</dependency>-->
    <!--<dependency>-->
        <!--<groupId>net.sourceforge.htmlunit</groupId>-->
        <!--<artifactId>htmlunit</artifactId>-->
        <!--<version>2.13</version>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>${selenium.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>${selenium.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-htmlunit-driver</artifactId>
        <version>${selenium.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <finalName>SpringMvcExample</finalName>
    <!--to run into debug mode set:-->
    <!--export MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n-->
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <path>/SpringMvcExample</path>
                <url>http://localhost:8080/manager/text</url>
                <server>tomcat7</server>
            </configuration>
        </plugin>
    </plugins>
</build>

4.0.0
com.savdev
SpringMvcExample
1.0-快照
网状物
1.0-快照
战争
SpringMVcExampleWebApp
3.2.4.1发布
2.37.1
UTF-8
com.savdev
模型
1.0-快照
com.savdev
服务
1.0-快照
爪哇
JavaEEAPI
7
假如
org.springframework
弹簧网
3.2.2.1发布
org.springframework
SpringWebMVC
3.2.2.1发布
javax.servlet
jstl
1.2
运行时
朱尼特
朱尼特
4.11
测试
org.springframework
弹簧试验
${spring.version}
测试
net.sourceforge.jwebunit
jwebunit核心
3.1
测试
org.seleniumhq.selenium
硒爪哇
${selenium.version}
测试
org.seleniumhq.selenium
selenium firefox驱动程序
${selenium.version}
测试
org.seleniumhq.selenium
硒铬驱动器
${selenium.version}
测试
org.seleniumhq.selenium
selenium htmlunit驱动程序
${selenium.version}
测试
SpringMvcExample
org.apache.tomcat.maven
tomcat7 maven插件
2.1
/SpringMvcExample
http://localhost:8080/manager/text
tomcat7

尝试将tomcat
运行
/
关闭
绑定到合适的
阶段:

<phase>pre-integration-test</phase>
<goals>
  <goal>run</goal>
</goals>
预集成测试
跑

集成后测试
关闭

将其配置为这样,您不应该手动启动tomcat(即通过
mvn tomcat7:run
)。它应该在测试前自动运行,并在测试后关闭。

请包括您的
pom.xml
<phase>post-integration-test</phase>
<goals>
  <goal>shutdown</goal>
</goals>