一,准备工作,建立spring-boot-sample-mysql工程Http://start.spring.io/ A、Artifact中输入spring-boot-sample-Mysql
一,准备工作,建立spring-boot-sample-mysql工程
A、Artifact中输入spring-boot-sample-Mysql
B、勾选WEB下的web
C、勾选sql下的JPA mysql
Eclips中导入工程spring-boot-sample-mysql
A、解压快捷工程spring-boot-sample-mysql到某文件夹
B、eclips中file->import->Import Existing Maven Projects-->Select Maven projects-->finish导入工程
工程导入之后,文件结构如下图
在包com.example下建立web文件夹
便于测试,引入spring-boot-sample-helloworld的HelloController及配置文件logback.xml
HelloController代码为
package com.example.web; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { protected static Logger logger=LoggerFactory.getLogger(HelloController.class); @RequestMapping("/") public String helloworld(){ logger.debug("访问hello"); return "Hello world!"; } @RequestMapping("/hello/{name}") public String helloName(@PathVariable String name){ logger.debug("访问helloName,Name={}",name); return "Hello "+name; } }
--结束END--
本文标题: SpringBoot入门系列之JPA mysql
本文链接: https://www.lsjlt.com/news/227146.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-06-06
2024-06-06
2024-06-05
2024-06-04
2024-06-04
2024-06-03
2024-06-03
2024-06-03
2024-06-04
2024-06-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0