28

我只是想仔细检查一下,有没有人找到或正在开发 Tomcat 7 插件?如果没有,是否有人有兴趣帮助我启动并运行它?

我想要另一个 Glassfish 的快速替代品,JBoss AS 6.0 对于快速模型来说还是有点重。

沃尔特

4

9 回答 9

41

它对我有用,如下所示。

我的设置.xml

 <server>  
   <id>local_tomcat</id>  
   <username>ray</username>  
   <password>password</password>  
 </server>  

我的插件配置

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

我的 tomcat-users.xml

 <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
  <user password="password" roles="manager-gui, manager-script" username="ray"/>
于 2010-12-29T09:46:53.080 回答
13

我使用来自 Apache 的官方Tomcat7 Maven 插件,如下所示:

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <path>/${project.artifactId}</path>
                    <port>8080</port>
                </configuration>
            </plugin>

并运行它:mvn tomcat7:run

于 2012-11-06T12:25:12.343 回答
8

Google 代码上有t7mp - 一个 Tomcat 7 Maven 插件。

Cargo(及其 Cargo Maven2 插件)也支持Tomcat 7(这是CARGO-790)。

Apache Tomcat Maven 插件 2.0-beta-1支持 Tomcat 7。

于 2010-09-15T12:52:10.147 回答
7

使用 maven cargo 您可以通过这种方式配置您的项目:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.0.6</version>
    <configuration>
        <container>
            <containerId>tomcat7x</containerId>
            <type>installed</type>
            <home>${catalina.home}</home>
        </container>
        <configuration>
            <type>existing</type>
            <home>${catalina.home}</home>
        </configuration>
        <deployer>
            <type>installed</type>
            <deployables>
                <deployable>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${project.artifactId}</artifactId>
                    <type>war</type>
                </deployable>
            </deployables>
        </deployer>
    </configuration>
</plugin>       

不要忘记配置您的catalina.home属性

您可以使用以下方式部署它:

mvn cargo:deploy
于 2011-05-16T12:23:21.613 回答
7

有Apache Tomcat 团队开发的Tomcat Maven Plugin 7 插件。

目前,您必须签出源并将其安装到本地存储库。之后,您可以在 pom 的插件部分使用它:

      <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.0-SNAPSHOT</version>
        <executions>
          <execution>
            <id>start-tomcat</id>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
                  <path>/</path>
                  <serverXml>src/main/tomcatconf/server.xml</serverXml>
                </configuration>
          </execution>
        </executions>
      </plugin>
于 2011-11-08T16:36:02.787 回答
5

在我连续三天出现此错误后,这是我的解决方案:

您用来连接的用户至少需要角色管理器脚本。在你的 /conf/tomcat-users.xml

<role rolename="manager-script"/>
<user username="test" password="test" roles="manager-script"/>

在您的 pom.xml 中,包含以下插件

    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.0</version>
      <configuration>
        <url>http://server.url:8080/manager/text</url>
        <path>/YourApp</path>
        <username>test</username>
        <password>test</password>
      </configuration>
    </plugin>

与我在互联网上发现的相反,您不需要编辑您的 maven setting.xml。可以直接在configuration-tag中配置tomcat7-maven-plugin

对 url-tag 的一句话:我测试了后缀

  • /经理
  • /经理/html
  • /经理/文本

其中只有 /manager/text 有效

我的版本:

  • 雄猫:7.0.33
  • Maven:3.0.4
  • tomcat7-maven-插件:2.0
  • 爪哇:1.7.0_07
于 2013-03-13T01:00:22.417 回答
2

我正在为我的嵌入式 tomcat 实例使用 tomcat7-maven-plugin。这是我的配置方式。由于我的应用程序需要 jaas 身份验证,因此我也可以在设置本身中提供该身份验证。

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <configuration>
    <!-- http port -->
        <port>8080</port>
        <path>/gcs-explorers</path>
        <contextFile>${basedir}/src/main/webapp/META-INF/context.xml</contextFile>
        <addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
        <systemProperties>
            <java.security.auth.login.config>${basedir}/conf/jaas.config</java.security.auth.login.config>
        </systemProperties>
        <url>http://127.0.0.1:8080/manager/html</url>
        <username>admin</username>
        <password>admin</password>
        <addContextWarDependencies>true</addContextWarDependencies>
        <addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
        <configurationDir>${basedir}</configurationDir>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>2.2.0</version>
            <type>jar</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.company.package.jaas</groupId>
            <artifactId>gcs-jaas</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <type>jar</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.company.gcs</groupId>
            <artifactId>package-file-share</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
</plugin>
于 2012-06-13T14:01:52.117 回答
0

实际上,标准插件对我有用。我只需要在 tomcat 用户中创建角色管理器脚本并将 url 参数更改为http://localhost:8080/manager/html以使其工作:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
        <url>http://localhost:8080/manager/html</url>
        <server>local</server>
        <path>/${project.artifactId}</path>
        <update>true</update>
    </configuration>
</plugin>
于 2013-01-17T10:18:07.860 回答
-1

对于 Tomcat 7,

第 1 步:服务器添加的模块选项卡

Document base: <PATH>\Apache-Tomcat-7.0.0\webapps\manager
Path: /manager

第 2 步:将 POM 更新为:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
          <url>http://localhost:8080/manager/text</url>
          <update>true</update>
                <warFile>target/${project.artifactId}-${project.version}.war</warFile>
                <path>/${project.artifactId}</path>
                <username>tomcat_user</username>
                <password>tomcat_password</password>
        </configuration>
</plugin>
于 2010-12-05T20:45:55.920 回答