2015-12-08 24 views
0

我想使用Spring和Maven的web服务,当我启动应用程序,我有这样的问题:春与Maven

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 
(default-cli) on project WebService: Command execution failed. Process 
exited with an error: 1 (Exit value: 1) -> [Help 1] 

我的pom.xml

<?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>fr.itevents</groupId> 
    <artifactId>WebService</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <name>WebService</name> 

    <properties> 
     <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.3.0.RELEASE</version> 
    </parent> 

    <dependencies> 
     <dependency> 
      <groupId>javax</groupId> 
      <artifactId>javaee-web-api</artifactId> 
      <version>7.0</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
        <compilerArguments> 
         <endorseddirs>${endorsed.dir}</endorseddirs> 
        </compilerArguments> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.3</version> 
       <configuration> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.6</version> 
       <executions> 
        <execution> 
         <phase>validate</phase> 
         <goals> 
          <goal>copy</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${endorsed.dir}</outputDirectory> 
          <silent>true</silent> 
          <artifactItems> 
           <artifactItem> 
            <groupId>javax</groupId> 
            <artifactId>javaee-endorsed-api</artifactId> 
            <version>7.0</version> 
            <type>jar</type> 
           </artifactItem> 
          </artifactItems> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

你能帮助我吗?

+0

请显示更多的错误输出。我猜这将揭示exec插件启动哪个进程的更多信息,以及为什么失败并返回非0退出代码。 –

+0

请提供完整的错误信息,这有助于追踪问题。 – Prateek

+0

您正在使用弹簧引导,然后使用弹簧引导而不是在其周围工作。删除所有的插件,只留下弹簧引导,并执行'mvn springBoot:run'。此外,移除您不需要的Java EE依赖关系,将会让您的生活更加艰难,春季初学者已经为您做好了准备。 –

回答

0

您正在使用Spring Boot,并且正在努力不使用它,至少在您的pom.xml中。首先,您不需要javaee-web-api依赖项。初学者的想法是那些管理所有需要的依赖关系。所以简单地删除它。这同样适用于spring-boot-starter,因为spring-boot-starter-web依赖关系暗示了这一点。

您已经定义了许多额外的插件,Spring Boot已经拥有所需的配置,现在您正在使用一个非常旧的版本覆盖或更糟。删除所有的插件,只留下Spring Boot之一。

所以你基本上需要做的只是去掉你的pom.xml这应该给你带来像下面这样的东西。

<?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>fr.itevents</groupId> 
<artifactId>WebService</artifactId> 
<version>1.0-SNAPSHOT</version> 
<packaging>war</packaging> 

<name>WebService</name> 

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <java.version>1.7</java.version> 
</properties> 
<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.3.0.RELEASE</version> 
</parent> 

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
    </plugins> 
</build> 
</project> 

专业提示:我会建议使用罐子而不是战争这样你可以简单地提供一个jar文件,然后执行java -jar WebService.jar和拥有一切启动和运行中没有时间。你不再需要这样的战争了。