测试Web和数据库

@Controller
@ResponseBody
@RequestMapping("/api")
public class Ceshiweb {
    int i=0;
    @GetMapping("/serverbrand")
    String se() {
        i++;
        System.out.println("前端触发"+i+"次");
        return "web启动成功"+i+"次";
    }
}

===============================================

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface Ceshishujuku {
    @Select("SELECT id FROM quanyuan_xsdzz ORDER BY `id` DESC LIMIT 1;")
    Integer se();
}
==============================================

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class Test {
    @Autowired
    private Ceshishujuku ceshishujuku;
    @org.junit.jupiter.api.Test
    void se(){
        System.out.println(ceshishujuku.se());
    }
}

posted @ 2022-01-21 10:19  1994小剑  阅读(45)  评论(0)    收藏  举报