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://www.scyingshan.cn/article/dsocdj.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 