使用cargo-maven2-plugin插件自动化部署项目时遇到的问题

     在《Maven实战》第239页-----使用cargo实现自动化部署,其中部署至本地web容器有两种方式,分别为standalone模式和existing模式,我选择的是existing模式,下面是我的配置,在account-web的pom文件中:


<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.0</version>
    <configuration>
       <container>
           <containerId>tomcat7x</containerId>
           <home>D:\apache-tomcat-7.0.77</home>
       </container>
       <configuration>
           <type>existing</type>
           <home>D:\apache-tomcat-7.0.77</home>
       </configuration>
    </configuration>
</plugin>


     在maven的settings.xml中配置了pluginGroup后,就可以在命令行进行调用了,在执行cargo命令前,应该先在父目录执行mvn  clean  install,将所有子模块打包安装,以便为其他模块提供依赖,书上少了这一步。没有这一步会出错。打包完后,紧接着进入子模块account-web目录下,执行mvn  cargo:start   .报错了:

---------------------------------------------------------------------------------------------------------------------------------

cargo-maven2-plugin:1.0:start failed: Cannot create configuration. There'
s no registered configuration for the parameters (container [id = [tomcat7x], ty
pe = [installed]], configuration type [existing]). Actually there are no valid t
ypes registered for this configuration. Maybe you've made a mistake spelling it?

----------------------------------------------------------------------------------------------------------------------------------


     原因是cargo-maven2-plugin插件的版本与tomcat版本有兼容关系,书上插件用的是1.0版本,tomcat为6.x;而我电脑上tomcat为7.x,所以我将cargo-maven2-plugin插件的版本升级为1.4.9就成功了:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.4.9</version>
    <configuration>
       <container>
           <containerId>tomcat7x</containerId>
           <home>D:\apache-tomcat-7.0.77</home>
       </container>
       <configuration>
           <type>existing</type>
           <home>D:\apache-tomcat-7.0.77</home>
       </configuration>
    </configuration>
</plugin>

    

    另外,虽然构建成功了,我指的是使用mvn  cargo:start命令后,显示构建成功,但是tomcat并没有一直维持启动状态,而是构建成功后就断开了,这时应该再执行mvn  cargo:run命令,访问路径为http://localhost:8080/account-web/signup.jsp,书上写的是http://localhost:8080/account-web-1.0.0-SNAPSHOT/signup.jsp路径不正确。其实你可以到tomcat的webapp目录下一看就知道

  

   最后一个问题是这种启动方式过程中可能会报某些类找不到的错误,例如[INFO] [talledLocalContainer] Exception in thread "pool-1-thread-1" java.lang.NoClassDefFoundError: javax/mail/URLName

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值