发表于: 2020-01-13 22:04:18

1 1150


一、今天完成的事

修改dal框架的项目

@Controller
public class VideoController {
   private static final Log log = LogFactory.getLog(VideoController.class);
   @Autowired
   VideoService videoService;
   @Autowired
   JSONObject jsonObject;

   @RequestMapping(value = "/a/u/application", method = RequestMethod.POST)
   public JSONObject getVideo(Long id) throws Exception {
       try {
           Video video = videoService.getVideoById(id);
           log.info("get video data is " + video);
           jsonObject.put("code", 0);
           jsonObject.put("message", "success");
           jsonObject.put("data",video);
           log.info("-------------------------get application end----------------------");
       } catch (Exception e) {
           log.error(e.getMessage());
           log.error("get application error,id is  " + id);
           jsonObject.put("code", -1);
           jsonObject.put("message","failed");
       }
       return jsonObject;
   }
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

   <context:annotation-config/>
   <context:component-scan base-package="com.jnshu"/>


   <bean id="scaClient"
         class="com.gemantic.common.sca.service.SCAClientBean">
       <property name="resource" value="client.composite"/>
   </bean>


   <!-- VideoService  -->
   <bean id="videoService"
         class="com.gemantic.common.sca.service.SCAClientServiceFactory">
       <property name="client" ref="scaClient" />
       <property name="component" value="VideoServiceComponent" />
       <property name="className"
                 value="com." />
   </bean>


   <!-- performance -->
   <aop:aspectj-autoproxy/>
   <bean id="aroundLoggingTime" class="com.gemantic.common.stat.aop.time.AroundTimeConsume"/>
   <aop:config>
       <aop:aspect ref="aroundLoggingTime">
           <aop:pointcut id="publicServiceMethod"
                         expression="execution(* com.gemantic..service.*.*(..)) &amp;&amp; (!execution(* com.gemantic.common.sca.service.*.*(..)))"/>
           <aop:around method="around" pointcut-ref="publicServiceMethod"/>
       </aop:aspect>
   </aop:config>
</beans>
package com.jnshu.util;

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

import java.util.Properties;

/**
* @author Admin
* @PackageName com.jnshu.academyctrlwebclient.util
* @ClassName dev
* @Description
* @create 2019-12-01 15:42
*/

public class SSHConnection {
   // 需要了可以打开
//private final static String S_PATH_FILE_PRIVATE_KEY = "/Users/xxx/.ssh/id_rsa";
// 需要了可以打开
//private final static String S_PATH_FILE_KNOWN_HOSTS = "/Users/xxx/.ssh/id_rsa/.ssh/known_hosts";

   /**
    * 自定义的中转接口,需要和数据源接口设置一样
    */
   private final static int LOCAL_PORT = 5555;

   /**
    *  服务端的数据库端口
    */
   private final static int REMOTE_PORT = 3306;

   /**
    *     服务器端SSH端口 默认是22
    */
   private final static int SSH_REMOTE_PORT = 22;
   /**
    *  SSH用户名
     */
   private final static String SSH_USER = "root";
   /**
    SSH使用密码
    */
   private final static String SSH_PASSWORD = "Rz2BYTbGGQY6Hnf";
   /**
    * 连接到哪个服务端的SSH
    */
   private final static String SSH_REMOTE_SERVER = "118.126.113.248";
   /**
    *   服务端的本地mysql服务
     */
   private final static String MYSQL_REMOTE_SERVER = "127.0.0.1";

   /**
    *  represents each ssh session
    */
   private Session sesion;

   /**
    *  测试连接
    */
   public static void main(String[] args) throws Throwable {
       System.out.println(new SSHConnection());
   }
   public SSHConnection() throws Throwable
   {

       JSch jsch = new JSch();
       // 需要用到了开启
       // jsch.setKnownHosts(S_PATH_FILE_KNOWN_HOSTS);
       //jsch.addIdentity(S_PATH_FILE_PRIVATE_KEY);

       sesion = jsch.getSession(SSH_USER, SSH_REMOTE_SERVER, SSH_REMOTE_PORT);
       sesion.setPassword(SSH_PASSWORD);

       Properties config = new Properties();
       config.put("StrictHostKeyChecking", "no");
       sesion.setConfig(config);
       // 去连接
       sesion.connect(); //ssh connection established!
       //  设置转发
       sesion.setPortForwardingL(LOCAL_PORT, MYSQL_REMOTE_SERVER, REMOTE_PORT);

       System.out.println("运行OK");
   }

   void closeSSH() {
       sesion.disconnect();
   }
}

二、遇到的问题

配置文件这里好像还没弄好,运行不起来

三、收获

四、明天的计划

继续dal



返回列表 返回列表
评论

    分享到