maven

38次阅读
没有评论

共计 1448 个字符,预计需要花费 4 分钟才能阅读完成。

今天就跟大家聊聊有关 maven-antrun-plugin 中无法调用 jsch shell target 该怎么办,可能很多人都不太了解,为了让大家更加了解,丸趣 TV 小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

将 Maven 项目的一键部署从原来的 http 上传改为:

compile 的时候连接 linux,关闭 tomcat,删除 logs、work,再启动 tomcat,最后打包部署。

考虑了采用 maven-antrun-plugin 插件,但是开始一直报错,找不到 jsch 这些 jar,但是单独运行 build.xml 又是好的。后来干脆直接在 build.xml 里面引入 jar 了,解决问题了,配置文件如下:

Pom.xml

plugin 
 groupId org.apache.maven.plugins /groupId 
 artifactId maven-antrun-plugin /artifactId 
 executions 
 execution 
 id compile /id 
  phase compile /phase 
 configuration 
   target 
   ant antfile= ${basedir}/build.xml 
   target name= test / 
   /ant 
   /target 
  /configuration 
 goals 
  goal run /goal 
 /goals 
 /execution 
 /executions 
 /plugin

build.xml

?xml version= 1.0  ? 
 project name = DKSNS-Java-Pro  default = test  basedir = . 
 property environment= env / 
  target name= test 
  echo message= compile classpath: ${env.ANT_HOME} / 
  path id= jsch.path  
  pathelement location= ${env.ANT_HOME}\lib\ant-jsch.jar  /  
  pathelement location= ${env.ANT_HOME}\lib\jsch-20130131.jar  /  
  /path  
  !--
  taskdef name= scp  classname= org.apache.tools.ant.taskdefs.optional.ssh.Scp  classpathref= jsch.path  /   
 --    
  taskdef name= sshexec  classname= org.apache.tools.ant.taskdefs.optional.ssh.SSHExec  classpathref= jsch.path  / 
  
  sshexec host= 192.168.81.132  username= root  password= 123456  trust= true 
 command= cd /usr/local/tomcat/bin;
   ./shutdown.sh;
   cd /usr/local/tomcat/logs;
   rm -rf *;
   cd /usr/local/tomcat/work;
   rm -rf *; 
  /sshexec 
 
  /target 
 /project

看完上述内容,你们对 maven-antrun-plugin 中无法调用 jsch shell target 该怎么办有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注丸趣 TV 行业资讯频道,感谢大家的支持。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-16发表,共计1448字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)