快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

SpringBoot入门系列之JPAmysql-创新互联

创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

成都创新互联公司专注于东源网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供东源营销型网站建设,东源网站制作、东源网页设计、东源网站官网定制、小程序制作服务,打造东源网络公司原创品牌,更为您提供东源网站排名全网营销落地服务。

一,准备工作,建立spring-boot-sample-mysql工程

1、http://start.spring.io/

     A、Artifact中输入spring-boot-sample-MySQL
     B、勾选Web下的web
     C、勾选SQL下的JPA MYSQL

2、Eclips中导入工程spring-boot-sample-mysql

     A、解压快捷工程spring-boot-sample-mysql到某文件夹

     B、eclips中file->import->Import Existing Maven Projects-->Select Maven projects-->finish导入工程

3、工程导入之后,文件结构如下图

4、在包com.example下建立web文件夹

5、便于测试,引入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; 
  } 
} 

网页题目:SpringBoot入门系列之JPAmysql-创新互联
分享路径:http://6mz.cn/article/dsocdj.html

其他资讯