【发布时间】:2010-09-15 01:33:36
【问题描述】:
我只是想仔细检查一下,是否有人找到或正在开发 Tomcat 7 插件?如果没有,是否有人有兴趣帮助我启动并运行它?
我想要另一个 Glassfish 的快速替代品,JBoss AS 6.0 对于快速模型来说还是有点重。
沃尔特
【问题讨论】:
标签: maven-2 maven-plugin tomcat7
我只是想仔细检查一下,是否有人找到或正在开发 Tomcat 7 插件?如果没有,是否有人有兴趣帮助我启动并运行它?
我想要另一个 Glassfish 的快速替代品,JBoss AS 6.0 对于快速模型来说还是有点重。
沃尔特
【问题讨论】:
标签: maven-2 maven-plugin tomcat7
它对我有用,如下所示。
我的设置.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"/>
【讨论】:
http://localhost:8080/manager,而 Tomcat 7 是 http://localhost:8080/manager/text
我使用来自 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
【讨论】:
在 Google 代码中有 t7mp - 一个 Tomcat 7 Maven 插件。
Cargo(及其 Cargo Maven2 插件)也支持Tomcat 7(原为CARGO-790)。
Apache Tomcat Maven Plugin 2.0-beta-1 支持 Tomcat 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
【讨论】:
有 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>
【讨论】:
在我连续三天出现此错误后,这是我的解决方案:
您用来连接的用户至少需要角色管理器脚本。 在你的 /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 的一句话:我测试了后缀
其中只有 /manager/text 有效
我的版本:
【讨论】:
我正在为我的嵌入式 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>
【讨论】:
实际上,标准插件对我有用。我只需要在 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>
【讨论】:
对于 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>
【讨论】: