sprintboot&docker&HelloWorld

sprintboot&docker&HelloWorld 初始化springboot项目 初始化springboot项目 新建HelloController @RestController public class HelloController { @RequestMapping(value = "/", method = RequestMethod.GET) public String hello() { return "hello docker demo"; } } ...

April 19, 2020

mac下安装k8s&docker及HelloWorld

mac下安装k8s&docker及HelloWorld 安装环境:macOS 安装docker 下载地址:https://hub.docker.com/editions/community/docker-ce-desktop-mac 无脑点击下一步即可 启用k8s 打开docker—preference—kurbernets,勾上Enable Kurbernets,注意,勾选上之后需要下载文件,这个过程比较耗时,需要耐心等待 ...

April 18, 2020

spring-eureka-hello-world

spring-eureka-hello-world 核心概念 spring-eureka:注册中心,实现服务注册和发现 Hello world代码地址 [spring-eureka](https://github.com/weizhaowu-se/spring-eureka) 注册中心server 初始化springboot(此处略去) 配置相关依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> <version>1.4.7.RELEASE</version> </dependency> ...

April 9, 2020

springboot集成mybatis及pageHelper的使用

springboot集成mybatis及pageHelper的使用 简单集成 新增maven依赖 <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version> </dependency> ...

March 2, 2020

springboot数据库与mybatis

springboot数据库与mybatis入门配置 初始化工程 参考链接:https://blog.csdn.net/typa01_kk/article/details/76696618 数据库配置以及测试 在application.properties配置如下 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test spring.datasource.username=root spring.datasource.password=password spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.max-idle=10 spring.datasource.max-wait=10000 spring.datasource.min-idle=5 spring.datasource.initial-size=5 通过jdbcTemplate的方式访问数据库 @RunWith(SpringRunner.class) @SpringBootTest public class DemoSpringbootApplicationTests { @Autowired JdbcTemplate jdbcTemplate; @Test public void contextLoads() { String sql = "select * from user"; List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql); System.out.println("query result:" + JSON.toJSONString(resultList)); for (Map<String, Object> item: resultList) { for (Map.Entry<String, Object> entry: item.entrySet()) { System.out.println(entry.getKey() + ":" + entry.getValue().toString()); System.out.println("\n"); } } } } 日志打印如下: query result:[{"id":1,"name":"test"}] id:1 name:test 成功访问数据库....

March 18, 2019