mac下maven关于cargo的tomcat6详细部署

本文详细记录了在Mac系统中如何解决Tomcat6启动问题及使用Maven的Cargo插件进行项目部署的过程。包括配置JAVA_HOME环境变量、赋予脚本执行权限、启动Tomcat,以及修改tomcat-users.xml、maven的settings.xml和项目pom.xml以实现mvn clean install和mvn cargo:redeploy。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

废话不多说,记下来,方便以后查阅

首先,下载tomcat6并解压到指定目录 重命名为tomcat

这时候当我们想启动tomcat的时候会出现如下错误:

deimmatoiMac-5:~ deim$ cd /Users/deim/Documents/work/tomcat/bin
deimmatoiMac-5:bin deim$ sh startup.sh
Cannot find ./catalina.sh
The file is absent or does not have execute permission
This file is needed to run this program



好,既然catalina.sh找不到,那不妨试试 打开 catalina.sh

deimmatoiMac-5:bin deim$ sh catalina.sh
The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program


经过google才知道是catalina.sh找不到JAVA_HOME,好,既然你找不到我就给你配。

JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home;

(该路径可由eclipse中拷贝)

修改好后再次执行 sh catalina.sh还是出现如下提示,这是因为没有执行权限

The BASEDIR environment variable is not defined correctly
This environment variable is needed to run this program



那就给所有的sh文件执行权限 chmod +x *.sh

好,再次sh catalina.sh

deimmatoiMac-5:bin deim$ sh catalina.sh
Using CATALINA_BASE:   /Users/deim/Documents/work/tomcat
Using CATALINA_HOME:   /Users/deim/Documents/work/tomcat
Using CATALINA_TMPDIR: /Users/deim/Documents/work/tomcat/temp
Using JRE_HOME:        /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH:       /Users/deim/Documents/work/tomcat/bin/bootstrap.jar
Usage: catalina.sh ( commands ... )
commands:
  debug             Start Catalina in a debugger
  debug -security   Debug Catalina with a security manager
  jpda start        Start Catalina under JPDA debugger
  run               Start Catalina in the current window
  run -security     Start in the current window with security manager
  start             Start Catalina in a separate window
  start -security   Start in a separate window with security manager
  stop              Stop Catalina, waiting up to 5 seconds for the process to end
  stop n            Stop Catalina, waiting up to n seconds for the process to end
  stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
  stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running
  version           What version of tomcat are you running?
Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined



行,那现在就执行下startup.sh试试

deimmatoiMac-5:bin deim$ sh startup.sh
Using CATALINA_BASE:   /Users/deim/Documents/work/tomcat
Using CATALINA_HOME:   /Users/deim/Documents/work/tomcat
Using CATALINA_TMPDIR: /Users/deim/Documents/work/tomcat/temp
Using JRE_HOME:        /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH:       /Users/deim/Documents/work/tomcat/bin/bootstrap.jar


oh yeah~跑起来了。第一步完成。


接下来就是部署maven项目到tomcat上了

1.tomcat的tomcat-users.xml

<role rolename="manager-gui"/>
    <role rolename="manager-script"/>
  <user password="admin" roles="manager-gui, manager-script" username="admin"/>


2.maven的setting.xml

<pluginGroup>org.codehaus.cargo</pluginGroup> 
.......
<server>
           <id>tomcat</id>
           <username>admin</username>
           <password>admin</password>
    </server>


3.maven项目的pom.xml

 

<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
<cargo.tomcat.manager.url>http://localhost:8080/manager</cargo.tomcat.manager.url>
</properties>
</configuration>
</configuration>   
 </plugin> 


好了,现在可以 mvn clean install 然后 mvn catgo:redeploy

注意:redeploy前tomcat必须已经启动







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值