maven-antrun-plugin中无法调用 jsch shell target该怎么办

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

将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该怎么办有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注蜗牛博客行业资讯频道,感谢大家的支持。

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接