简体   繁体   English

tomcat7 maven插件忽略配置

[英]tomcat7 maven plugin ignoring configuration

my Probelm is, when running mvn tomcat:[re]deploy i get HTTP returncode 403 from http://localhost:8080/manager , regardless of what url i specify for the tomcat plugin 我的Probelm是,当运行mvn tomcat时:[重新]部署我从http://localhost:8080/manager获取HTTP返回码403,无论我为tomcat插件指定了什么url

I found out in other Questions that 我在其他问题中发现了这一点

<url>http://localhost:8080/manager/text</url>

should be what i aim for, 应该是我的目标,

but maven completley ignores this xml-tag, it always goes for /manager/deploy, even if i put complete rubbish like, 但是maven completley忽略了这个xml-tag,它总是用于/ manager / deploy,即使我把完全垃圾一样,

 <url>http://localhost:8080/nana/</url>

What i tried: 我尝试了什么:

  • Restarting the tomcat, 重启tomcat,
  • checked spelling of url and username/password, 检查网址和用户名/密码的拼写,
  • tomcat is running, tomcat正在运行,
  • i can login with the username "mavendeployer" over the gui if i add manager-gui as role 如果我添加manager-gui作为角色,我可以使用用户名“mavendeployer”登录gui
  • mvn install works fine mvn安装工作正常
  • searched the whole Project for occurences of /manager - nothing found (if /nana is put as url) 在整个项目中搜索了/ manager的出现 - 没有找到(如果/ nana被设为url)
  • removed the <version> tag from the tomcat7-plugin in .pom, trying to ensure that it was not the version i used that acts funny with my version of tomcat 从.pom中的tomcat7-plugin中删除了<version>标记,试图确保它不是我使用的版本与我的tomcat版本一样有趣

i am using maven 3.0.5, tomcat7, whatever version Maven provides for the plugin 我正在使用maven 3.0.5,tomcat7,Maven为插件提供的任何版本

my tomcat-user: 我的tomcat用户:

    <user username="mavendeployer" 
          password="maven" 
          roles = "manager-script,admin-script" />

my maven server-settings: 我的maven服务器设置:

<server>
    <id>localtomcat</id>
     <username>mavendeployer</username>
    <password>maven</password>
</server>

my pom: (deleted a lot of dependencies to keep it short, the build works fine, just mvn tomcat:[re]deploy fails: 我的pom :(删除了很多依赖项以保持简短,构建工作正常,只是mvn tomcat:[re] deploy失败:

<?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>net.test</groupId>
  <artifactId>testApp</artifactId>
  <packaging>war</packaging>
  <!-- <server SW version>-<REST interface version> -->
  <version>1.6.4-1.0.3</version>
  <name>Test</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
    </dependency>
      ...javax.servlet
      ...javax.servlet.jsp
      ...
         </dependencies>

  <build>
    <finalName>test</finalName>
    <plugins>
      <!-- Maven Tomcat Plugin -->
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <configuration>
          <url>http://localhost:8080/nana/</url>
          <server>localtomcat</server>
          <path>/mim</path>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>  
    </plugins>
  </build>
</project>

I don't seem to be able to find a Question where changing url to /manager/text or manager/html did not solve the 403 issue, what am i missing? 我似乎无法找到一个问题,如果更改URL / manager / text或manager / html没有解决403问题,我缺少什么?

ok, the Solution was very very tricky! 好的,解决方案非常棘手! The target is not tomcat:[re]depoly, it is tomcat* 7 *:[re]deploy^^, thanks anyway 目标不是tomcat:[re] depoly,它是tomcat * 7 *:[重新]部署^^,谢谢

The following works for me: 以下适用于我:

My tomcat-users.xml - Note the role element : 我的tomcat-users.xml - 注意角色元素

<tomcat-users>
  <role rolename="manager-script"/>
  <user username="mavendeployer" password="maven" roles="manager-script"/>
</tomcat-users>

My pom.xml : 我的pom.xml

<build>
  <finalName>your_web_app_name</finalName>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.1</version>
      </plugin>
    </plugins>
  </pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <configuration>
        <server>localtomcat</server>
        <update>true</update>
        <url>http://localhost:8080/manager/text</url>
      </configuration>
    </plugin>
  </plugins>
</build>

Your Maven settings.xml seems fine to me. 您的Maven settings.xml对我来说似乎很好。

If this still doesn't work, let me know and I'll look for other settings/configuration. 如果这仍然不起作用,请告诉我,我会寻找其他设置/配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM