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
Maven Overlay:基本项目总是在安装时启动tomcat_Maven - Fatal编程技术网

Maven Overlay:基本项目总是在安装时启动tomcat

Maven Overlay:基本项目总是在安装时启动tomcat,maven,Maven,我有3个项目:家长,基地和演示 父级用于全局插件和依赖项: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.

我有3个项目:家长,基地和演示

父级用于全局插件和依赖项:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <packaging>pom</packaging>

    <properties>

        <!-- Generic properties -->
        <java.version>1.6</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Spring -->
        <spring.version>3.2.2.RELEASE</spring.version>

        <!-- Servlet -->
        <jstl.version>1.2</jstl.version>
        <servlet.version>2.5</servlet.version>

        <!-- Logging -->
        <slf4j.version>1.7.5</slf4j.version>
        <log4j.version>1.2.17</log4j.version>

        <!-- Test -->
        <junit.version>4.11</junit.version>

        <!-- Apache Tiles -->
        <tiles.version>2.2.2</tiles.version>

    </properties>

    <dependencies>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>

        <!-- Apache Tiles -->
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-jsp</artifactId>
            <version>${tiles.version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging-api</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>

    </dependencies>

    <build>

        <defaultGoal>install</defaultGoal>

        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <compilerArguments>
                        <Xlint />
                    </compilerArguments>
                    <verbose>true</verbose>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
            </plugin>

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                </configuration>
                <executions>
                    <execution>
                        <id>tomcat-run</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                    </execution>
                    <execution>
                        <id>tomcat-shutdown</id>
                        <goals>
                            <goal>shutdown</goal>
                        </goals>
                        <phase>post-integration-test</phase>
                    </execution>
                </executions>
            </plugin>

        </plugins>

    </build>

</project>

4.0.0
com.example
父母亲
0.0.1-快照
聚甲醛
1.6
UTF-8
UTF-8
3.2.2.1发布
1.2
2.5
1.7.5
1.2.17
4.11
2.2.2
org.springframework
spring上下文
${spring.version}
公用记录
公用记录
org.springframework
SpringWebMVC
${spring.version}
javax.servlet
servlet api
${servlet.version}
假如
javax.servlet
jstl
${jstl.version}
org.slf4j
slf4j api
${slf4j.version}
org.slf4j
jcl-over-slf4j
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
运行时
log4j
log4j
${log4j.version}
运行时
朱尼特
朱尼特
${junit.version}
org.apache.tiles
平铺jsp
${tiles.version}
公用记录
通用日志api
安装
org.apache.maven.plugins
maven编译器插件
3
真的
${java.version}
${java.version}
真的
org.apache.maven.plugins
maven战争插件
2.3
org.apache.tomcat.maven
tomcat7 maven插件
2
src/main/webapp/WEB-INF/WEB.xml
雄猫赛跑
跑
预集成测试
tomcat关机
关闭
整合后测试
Base是基本的Spring配置(Servlet、控制器等):


4.0.0
com.example
基础
0.0.1-快照
战争
com.example
父母亲
0.0.1-快照
安装
演示是针对Spring JSP的:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <packaging>war</packaging>

    <parent>
        <groupId>com.example</groupId>
        <artifactId>parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>base</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>runtime</scope>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>tomcat:run</defaultGoal>
    </build>

</project>

4.0.0
com.example
演示
0.0.1-快照
战争
com.example
父母亲
0.0.1-快照
com.example
基础
0.0.1-快照
运行时
战争
雄猫:快跑
安装父项目就像一个符咒(可以在本地m2存储库中找到它),但是安装基本项目总是运行tomcat?!我只想构建war并将其安装到本地m2存储库中。这里怎么了


ps:我不喜欢总是提到依赖项和插件,所以最好把它们放在父项目中,因为我在每个子项目(例如演示)中都需要它们。

您的
默认目标是
安装
,然后在
预集成测试中绑定
tomcat运行
。因此,一旦启动
maven安装
,它将在执行
预集成测试
阶段的同时执行
tomcat运行

检查maven生命周期:了解

因此,您应该更新您的
tomcat7 maven插件
,并删除执行。如果你仍然想保留这些,那么你应该考虑使用一些(构建敌人的特定配置文件示例)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <packaging>war</packaging>

    <parent>
        <groupId>com.example</groupId>
        <artifactId>parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>base</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>runtime</scope>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>tomcat:run</defaultGoal>
    </build>

</project>