问题描述
- 关于maven远程部署多模块web项目到tomcat失败问题
- 主模块:
<?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>
service模块:
<?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>
web2模块:
<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>
运行tomcat7:redeploy时抛出异常,有关tomcat7-maven-plugin插件都会抛出异常,这里写的很明白是因为没找到service的jar,但是问题是他是子模块,我不需要这个子模块跑到本地仓库或者远程仓库啊,我只需要他在WEB-INF下的lib里就可以了,他现在是在的。求解决:
[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
运行tomcat7:redeploy时抛出异常,有关tomcat7-maven-plugin插件都会抛出异常,这里写的很明白是因为没找到service的jar,但是问题是他是子模块,我不需要这个子模块跑到本地仓库或者远程仓库啊,我只需要他在WEB-INF下的lib里就可以了,他现在是在的。求解决
解决方案
时间: 2024-10-30 16:49:16