当我不想用 tomcat 部署我的 maven 项目时,我遇到了问题。我只得到一个 404。当我用码头尝试它时,它工作正常。
我认为 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.shoot.tail</groupId>
<artifactId>shootout</artifactId>
<packaging>war</packaging>
<version>1.2</version>
<name>Shootout</name>
<repositories>
<repository>
<id>java.net</id>
<url>https://maven.java.net/content/repositories/releases</url>
</repository>
</repositories>
<properties>
<myfaces.version>2.1.8</myfaces.version>
<mojarra.version>2.1.11</mojarra.version>
<jetty.version>8.1.5.v20120716</jetty.version>
<tomcat.version>7.0.12</tomcat.version>
</properties>
<profiles>
<profile>
<id>mojarra</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${mojarra.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${mojarra.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>jdbc-pool</artifactId>
<version>${jdbc-pool.version}</version>
<scope>system</scope>
<systemPath>${basedir}/../${web.project}/WebContent/WEB-INF/lib/tomcat-jdbc.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>juli</artifactId>
<version>${tomcat.version}</version>
</dependency>
</dependencies>
<properties>
<override-web-xml>src/main/jetty/override-mojarra-web.xml</override-web-xml>
</properties>
</profile>
<profile>
<id>myfaces</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>${myfaces.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>${myfaces.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<override-web-xml>src/main/jetty/override-myfaces-web.xml</override-web-xml>
</properties>
</profile>
</profiles>
<!-- Project dependencies -->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>shootout</finalName>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>${tomcat.version}</version>
<configuration>
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
<overrideDescriptor>${override-web-xml}</overrideDescriptor>
</webAppConfig>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
<overrideDescriptor>${override-web-xml}</overrideDescriptor>
</webAppConfig>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<wtpversion>2.0</wtpversion>
<downloadSources>true</downloadSources>
<additionalProjectFacets>
<jst.jsf>2.0</jst.jsf>
</additionalProjectFacets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
版本 Eclipse:Juno Tomcat:7.0.12 Maven:3.0.5
和错误:
[ERROR] Plugin org.codehaus.mojo:tomcat-maven-plugin:7.0.12 or one of its depend
encies could not be resolved: Failed to read artifact descriptor for org.codehau
s.mojo:tomcat-maven-plugin:jar:7.0.12: Failure to find org.codehaus.mojo:tomcat-
maven-plugin:pom:7.0.12 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.plugin.PluginResolutionException: Plugin org.codehaus.mojo:tomc
at-maven-plugin:7.0.12 or one of its dependencies could not be resolved: Failed
to read artifact descriptor for org.codehaus.mojo:tomcat-maven-plugin:jar:7.0.12
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.re
solve(DefaultPluginDependenciesResolver.java:129)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginD
escriptor(DefaultMavenPluginManager.java:142)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDes
criptor(DefaultMavenPluginManager.java:261)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(D
efaultBuildPluginManager.java:185)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDesc
riptor(MojoDescriptorCreator.java:235)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalcul
ator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:106)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalcul
ator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:86)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:98)
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(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to
read artifact descriptor for org.codehaus.mojo:tomcat-maven-plugin:jar:7.0.12
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:296)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
readArtifactDescriptor(DefaultArtifactDescriptorReader.java:186)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.readArtifac
tDescriptor(DefaultRepositorySystem.java:279)
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.re
solve(DefaultPluginDependenciesResolver.java:115)
... 20 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Failure t
o find org.codehaus.mojo:tomcat-maven-plugin:pom:7.0.12 in http://repo.maven.apa
che.org/maven2 was cached in the local repository, resolution will not be reatte
mpted until the update interval of central has elapsed or updates are forced
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(Def
aultArtifactResolver.java:538)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
facts(DefaultArtifactResolver.java:216)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
fact(DefaultArtifactResolver.java:193)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:281)
... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Failure to fi
nd org.codehaus.mojo:tomcat-maven-plugin:pom:7.0.12 in http://repo.maven.apache.
org/maven2 was cached in the local repository, resolution will not be reattempte
d until the update interval of central has elapsed or updates are forced
at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.newExcept
ion(DefaultUpdateCheckManager.java:230)
at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.checkArti
fact(DefaultUpdateCheckManager.java:204)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(Def
aultArtifactResolver.java:427)
... 26 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResoluti
onException
非常感谢你的帮助。最好的祝愿罗伯特