2013-03-15 178 views
2

当我不想用tomcat部署我的maven项目时,出现问题。我只能得到404。 当我用jetty试用它时,它工作正常。在Tomcat中部署Maven项目

我觉得有些不对的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 :朱诺 的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 

非常感谢您的帮助。 最良好的祝愿 罗伯特

+0

完整的文章你构建过程中遇到任何错误/部署? – 2013-03-15 00:52:10

+0

是的,我加了。 – BobBarker 2013-03-15 01:15:32

回答

1

您指定的Tomcat版本,而不是tomcat的Maven的插件版本,引起行家来没有找到该插件(实际读取错误消息应该帮助你);在这里:

<properties> 
    <tomcat.version>7.0.12</tomcat.version> 
</properties> 
[...] 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>tomcat-maven-plugin</artifactId> 
      <version>${tomcat.version}</version> 
      [...] 

使用1.2快照(例如)为$ {} tomcat.version或者其他地方使用的Tomcat版本声明另一个变量。

另外,Tomcat的7.0需求additional configuration用于交互的Web应用程序管理器,像这样:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>tomcat-maven-plugin</artifactId> 
    <version>1.2-SNAPSHOT</version> 
    <configuration> 
    <url>http://localhost:8080/manager/html</url> 
    </configuration> 
</plugin> 

或者,你可以使用2.x版这一直moved下的Apache,并在mojos已更名为tomcat6和tomcat7具有相同的目标。

<pluginManagement> 
    <plugins> 
    <plugin> 
     <groupId>org.apache.tomcat.maven</groupId> 
     <artifactId>tomcat6-maven-plugin</artifactId> 
     <version>2.1</version> 
    </plugin> 
    <plugin> 
     <groupId>org.apache.tomcat.maven</groupId> 
     <artifactId>tomcat7-maven-plugin</artifactId> 
     <version>2.1</version> 
    </plugin> 
    </plugins> 
</pluginManagement> 
+0

谢谢,我更进一步。 [警告]在构建有效设置时遇到了一些问题 [警告]无法识别的标记:'id'(位置:START_TAG见过... \ n \ t ... @ 112:8)@ C :\ Software \ maven \ conf \ settings.xml,第112行,第8列 [警告] [INFO]扫描项目... [警告] POM for org.codehaus.mojo:tomcat-maven-plugin:罐子:1.2快照 丢失,可用的依赖信息 C:\ SOFTWARE \行家\的conf \ settings.xml的线路112 TomcatServer 管理 admin BobBarker 2013-03-15 02:18:45

+0

似乎移动到apache之后,codehaus存储库仅托管版本1.0。阅读关于此问题的第一个和第二个答案:http://stackoverflow.com/questions/2013576/maven-is-failing-to-download-the-tomcat-maven-plugin-snapshot – 2013-03-15 02:29:13

+0

谢谢,我认为这有帮助,但还有另一个问题,我发布在一个新的答案更好的阅读 – BobBarker 2013-03-15 11:14:11

1

是的,看起来更好。

我认为它尝试部署项目,但得到构建失败。

[INFO] Error stacktraces are turned on. 
[WARNING] 
[WARNING] Some problems were encountered while building the effective settings 
[WARNING] Unrecognised tag: 'id' (position: START_TAG seen ...<servers>\n \t<id 
>... @112:8) @ C:\Software\maven\conf\settings.xml, line 112, column 8 
[WARNING] 
[INFO] Scanning for projects... 
[WARNING] The POM for org.codehaus.mojo:tomcat7-maven-plugin:jar:2.0-SNAPSHOT is 
missing, no dependency information available 
[WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:tomcat7-mav 
en-plugin:2.0-SNAPSHOT: Plugin org.codehaus.mojo:tomcat7-maven-plugin:2.0-SNAPSH 
OT or one of its dependencies could not be resolved: Failed to read artifact des 
criptor for org.codehaus.mojo:tomcat7-maven-plugin:jar:2.0-SNAPSHOT 
Downloading: http://repository.apache.org/content/groups/snapshots-group/org/apa 
che/maven/plugins/maven-metadata.xml 
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xm 
l from/to apache.snapshots (http://repository.apache.org/content/groups/snapshot 
s-group/): Failed to transfer file: http://repository.apache.org/content/groups/ 
snapshots-group/org/apache/maven/plugins/maven-metadata.xml. Return code is: 500 
, ReasonPhrase:Server Error. 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Shootout 1.2 
[INFO] ------------------------------------------------------------------------ 
[WARNING] The POM for org.codehaus.mojo:tomcat7-maven-plugin:jar:2.0-SNAPSHOT is 
missing, no dependency information available 
[WARNING] Failed to retrieve plugin descriptor for org.codehaus.mojo:tomcat7-mav 
en-plugin:2.0-SNAPSHOT: Plugin org.codehaus.mojo:tomcat7-maven-plugin:2.0-SNAPSH 
OT or one of its dependencies could not be resolved: Failed to read artifact des 
criptor for org.codehaus.mojo:tomcat7-maven-plugin:jar:2.0-SNAPSHOT 
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from h 
ttp://repository.apache.org/content/groups/snapshots-group/ was cached in the lo 
cal repository, resolution will not be reattempted until the update interval of 
apache.snapshots has elapsed or updates are forced. Original error: Could not tr 
ansfer metadata org.apache.maven.plugins/maven-metadata.xml from/to apache.snaps 
hots (http://repository.apache.org/content/groups/snapshots-group/): Failed to t 
ransfer file: http://repository.apache.org/content/groups/snapshots-group/org/ap 
ache/maven/plugins/maven-metadata.xml. Return code is: 500 , ReasonPhrase:Server 
Error. 
[INFO] 
[INFO] >>> tomcat-maven-plugin:1.1:deploy (default-cli) @ shootout >>> 
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ shootout - 
-- 
[debug] execute contextualize 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent! 
[INFO] Copying 1 resource 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ shootout --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ sh 
ootout --- 
[debug] execute contextualize 
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent! 
[INFO] Copying 0 resource 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ shoot 
out --- 
[INFO] Nothing to compile - all classes are up to date 
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ shootout --- 
[INFO] Surefire report directory: C:\Software\workspace\shootout\target\suref 
ire-reports 

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 

Results : 

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 

[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ shootout --- 
[INFO] Packaging webapp 
[INFO] Assembling webapp [shootout] in [C:\Software\workspace\shootout\target 
\shootout] 
[INFO] Processing war project 
[INFO] Copying webapp resources [C:\Software\workspace\shootout\src\main\weba 
pp] 
[INFO] Webapp assembled in [47 msecs] 
[INFO] Building war: C:\Software\workspace\shootout\target\shootout.war 
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ig 
nored 
(webxml attribute is missing from war task, or ignoreWebxml attribute is specifi 
ed as 'true') 
[INFO] 
[INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) @ shootout <<< 
[INFO] 
[INFO] --- tomcat-maven-plugin:1.1:deploy (default-cli) @ shootout --- 
[INFO] Deploying war to http://localhost:8080/shootout 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3.682s 
[INFO] Finished at: Fri Mar 15 10:21:19 CET 2013 
[INFO] Final Memory: 10M/24M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy 
(default-cli) on project shootout: Cannot invoke Tomcat manager: Connection refu 
sed: connect -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o 
rg.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project shootou 
t: Cannot invoke Tomcat manager 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor 
.java:217) 
     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.buildProje 
ct(LifecycleModuleBuilder.java:84) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje 
ct(LifecycleModuleBuilder.java:59) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu 
ild(LifecycleStarter.java:183) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl 
eStarter.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(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.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat 
manager 
     at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalin 
aMojo.java:149) 
     at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarC 
atalinaMojo.java:70) 
     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default 
BuildPluginManager.java:101) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor 
.java:209) 
     ... 19 more 
Caused by: java.net.ConnectException: Connection refused: connect 
     at java.net.DualStackPlainSocketImpl.connect0(Native Method) 
     at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketI 
mpl.java:69) 
     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.ja 
va:339) 
     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocket 
Impl.java:200) 
     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java 
:182) 
     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) 
     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) 
     at java.net.Socket.connect(Socket.java:579) 
     at java.net.Socket.connect(Socket.java:528) 
     at sun.net.NetworkClient.doConnect(NetworkClient.java:180) 
     at sun.net.www.http.HttpClient.openServer(HttpClient.java:378) 
     at sun.net.www.http.HttpClient.openServer(HttpClient.java:473) 
     at sun.net.www.http.HttpClient.<init>(HttpClient.java:203) 
     at sun.net.www.http.HttpClient.New(HttpClient.java:290) 
     at sun.net.www.http.HttpClient.New(HttpClient.java:306) 
     at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC 
onnection.java:995) 
     at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne 
ction.java:931) 
     at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection 
.java:849) 
     at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:597) 

     at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java: 
662) 
     at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295) 

     at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDepl 
oyWarMojo.java:85) 
     at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDep 
loyMojo.java:85) 
     at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalin 
aMojo.java:141) 
     ... 22 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/MojoExecutionE 
xception 

C:\ SOFTWARE \行家\的conf \ settings.xml中:行111-115

<servers> 
    <id>tomcat</id> 
    <username>admin</username> 
    <password>admin</password> 
    </servers> 

的pom.xml

<repositories> 
[...] 
     <repository> 
      <id>people.apache.snapshots</id> 
      <url>http://repository.apache.org/content/groups/snapshots-group/</url> 
      <releases> 
       <enabled>false</enabled> 
      </releases> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </repository> 
    </repositories> 
[...] 
    <pluginRepositories> 
     <pluginRepository> 
      <id>apache.snapshots</id> 
      <name>Apache Snapshots</name> 
      <url>http://repository.apache.org/content/groups/snapshots-group/</url> 
      <releases> 
       <enabled>false</enabled> 
      </releases> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </pluginRepository> 
    </pluginRepositories> 
[...] 
    <build> 
     <finalName>shootout</finalName> 
     <defaultGoal>install</defaultGoal> 
     <plugins> 
      <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> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <version>2.0-SNAPSHOT</version> 
       <configuration> 
        <url>http://localhost:8080/manager/html</url> 
        <server>tomcat</server> 
        <username>admin</username> 
        <password>admin</password> 
       </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> 

      </plugins> 
     </pluginManagement> 
    </build> 

感谢您的帮助和有关量遗憾的问题。 robert

4

已解决。

这是我最后的pom.xml:

[...] 
    <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>tomcat-maven-plugin</artifactId> 
     <configuration> 
     <server>tomcat</server> 
     <url>http://localhost:8080/manager/text</url> 
     </configuration> 
    </plugin> 
[...] 

感谢圭多您的帮助(:

2

这个工程:

https://stackoverflow.com/a/16592276/503601

有在插件中的错误。这个插件不读取标签url。

<configuration> 
    <url>http://localhost:8080/manager/html</url> 
</configuration> 

设置属性使用

<properties> 
    <maven.tomcat.url>http://localhost:8080/manager/text</maven.tomcat.url> 
</properties> 

http://jvm-java.blogspot.com.es/2013/06/publish-with-maven-in-tomcat7.html

+0

感谢您指出这一点。我使用的是2.2版本的tomcat7-maven-plugin,并且已经证实了这一点。也想注意到这个属性条目必须被硬编码到你将部署一场战争的每个pom文件中。例如,在我的例子中,我有一个共同的父Maven Spring mvc项目,我所有的Maven战争项目都是从这个项目继承而来的,通常我会在父Pom中放置公共属性。对于这个特定的属性,你放在父pom中的任何值/ URI都会被忽略。我甚至试图在父类中创建一个自定义属性,然后将其注入为 $ {myCustonUri}总是无知 – Selwyn 2014-10-14 10:03:24