2016-05-06 18 views
0

我有一個問題,當我執行 'tomcat7-行家-插件'關於多模塊行家遠程部署失敗

  • 的pom.xml(包裝POM,具有兩個模塊)
  • 服務
    • 的pom.xml(包裝罐)
  • web2的
    • 的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>DeployTest</groupId> 
    <artifactId>DeployTest</artifactId> 
    <packaging>pom</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <modules> 
     <module>web2</module> 
     <module>service</module> 
    </modules> 
    <build> 
     <finalName>DeployTest</finalName> 
     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
        <encoding>UTF-8</encoding> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

兒童服務:

<?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"> 
    <parent> 
     <artifactId>DeployTest</artifactId> 
     <groupId>DeployTest</groupId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 
    <artifactId>service</artifactId> 
    <groupId>service</groupId> 
    <version>1.0</version> 
</project> 

孩子的Web:

<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/maven-v4_0_0.xsd"> 
    <parent> 
     <artifactId>DeployTest</artifactId> 
     <groupId>DeployTest</groupId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 
    <artifactId>web2</artifactId> 
    <packaging>war</packaging> 
    <name>web2 Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
     <dependency> 
      <groupId>service</groupId> 
      <artifactId>service</artifactId> 
      <version>1.0</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <finalName>web2</finalName> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <version>2.1</version> 
       <configuration> 
        <url>http://192.168.1.109:8080/manager/text</url> 
        <username>admin</username> 
        <password>admin</password> 
        <server>tomcat</server> 
        <path>/DeployTest</path> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

Whe n個I運行 'tomcat7:重新部署',拋出異常:

[ERROR] Failed to execute goal on project web2: Could not resolve dependencies for project DeployTest:web2:war:1.0-SNAPSHOT: Failure to find service:service:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project web2: Could not resolve dependencies for project DeployTest:web2:war:1.0-SNAPSHOT: Failure to find service:service:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced 
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:210) 
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:117) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:258) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:201) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project DeployTest:web2:war:1.0-SNAPSHOT: Failure to find service:service:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced 
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:189) 
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:185) 
    ... 32 more 

請幫我... 謝謝...

回答

0

最後,我找到了一種方法。

來自網絡的pom.xml刪除以下代碼:

<build> 
     <finalName>DeployTest</finalName> 
     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
        <encoding>UTF-8</encoding> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

添加以下代碼在父母的pom.xml <build>節點:

  <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-install-plugin</artifactId> 
       <version>2.5.2</version> 
       <executions> 
        <execution> 
         <id>deploy_install</id> 
         <phase>package</phase> 
         <goals> 
          <goal>install</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <version>2.2</version> 
       <configuration> 
        <url>http://192.168.1.109:8080/manager/text</url> 
        <username>admin</username> 
        <password>admin</password> 
        <path>/DeployTest</path> 
       </configuration> 
      </plugin> 
0

在你的孩子服務的pom.xml,刪除行<groupId>service</groupId>

在您的孩子的Web pom.xml中,引用服務項目有:

<dependencies> 
    <dependency> 
     <groupId>${project.groupId}</groupId> 
     <artifactId>service</artifactId> 
     <version>${project.version}</version> 
    </dependency> 
</dependencies> 
+0

謝謝您的回答,但問題依然存在..... changes..Failure DeployTest:service:jar:1.0在http://repo.maven.apache.org/maven2緩存在本地存儲庫中, – zhangbowen

+0

刪除' 1.0'from service pom。 xml以及...並添加' jar'there – Pras

+0

運行命令時我不能引用子模塊嗎? – zhangbowen