Chat/src/main/java/com/example/chat/dao/Test01.java

29 lines
844 B
Java
Raw Normal View History

2023-11-14 18:19:47 +08:00
package com.example.chat.dao;
import com.example.chat.dao.mybatis.MybatisSingleton;
import com.example.chat.entity.User;
import org.apache.ibatis.session.SqlSession;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
2023-11-21 13:07:56 +08:00
2023-11-14 18:19:47 +08:00
import java.util.concurrent.TimeUnit;
2023-11-21 13:07:56 +08:00
2023-11-14 18:19:47 +08:00
@Component
public class Test01 implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
2023-11-21 13:07:56 +08:00
while (true) {
SqlSession sqlSession = MybatisSingleton.getSqlSessionFactory().openSession();
User user = sqlSession.selectOne("dao.Login.getUser", "123");
if (user != null) {
2023-11-14 18:19:47 +08:00
System.out.println(user);
}
sqlSession.close();
System.out.println("sleep");
TimeUnit.HOURS.sleep(2);
}
}
}