You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package Tools;
|
|
|
|
|
|
|
|
|
|
import com.dsideal.FengHuang.Util.SSHUtil;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
public class CopyLib {
|
|
|
|
|
//在独立的main函数中,使用下面的方式进行声明logback对象
|
|
|
|
|
private final static Logger log = LoggerFactory.getLogger(CopyLib.class);
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
//主机
|
|
|
|
|
String host = "192.168.15.68";
|
|
|
|
|
String user = "root";
|
|
|
|
|
String pwd = "DsideaL4r5t6y7u!@#";
|
|
|
|
|
int port = 22;
|
|
|
|
|
//声明SSH对象
|
|
|
|
|
SSHUtil ssh = new SSHUtil(user, pwd, host, port);
|
|
|
|
|
ssh.connect();
|
|
|
|
|
//准备工作
|
|
|
|
|
ssh.exec("mkdir -p /usr/local/tomcat8/webapps/FengHuang/WEB-INF/lib");
|
|
|
|
|
//先删除远程的jar包
|
|
|
|
|
ssh.exec("mkdir -p /usr/local/tomcat8/webapps/FengHuang/WEB-INF/lib");
|
|
|
|
|
String libPath = "D:\\dsWork\\FengHuangJava\\lib";
|
|
|
|
|
String targetLibPath = "/usr/local/tomcat8/webapps/FengHuang/WEB-INF/lib";
|
|
|
|
|
ssh.exec("rm -rf " + targetLibPath + "/*.*");
|
|
|
|
|
//上传
|
|
|
|
|
File file = new File(libPath);
|
|
|
|
|
File[] tempList = file.listFiles();
|
|
|
|
|
for (int i = 0; i < tempList.length; i++) {
|
|
|
|
|
if (tempList[i].isFile())
|
|
|
|
|
ssh.upload(tempList[i].getAbsolutePath(), targetLibPath + "/" + tempList[i].getName());
|
|
|
|
|
log.info("成功上传文件" + tempList[i].getName());
|
|
|
|
|
}
|
|
|
|
|
//断开连接
|
|
|
|
|
ssh.disconnect();
|
|
|
|
|
log.info("恭喜,所有工作成功完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|