yangyang12138

导航

spring-boot启动web项目

1.依赖

<parent>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
       <version>1.4.3</version> </parent>
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-boot-starter-web</artifactId>
       <version>1.4.3</version> </dependency>

2.启动类

@SpringBootApplication
public class SelfApplication {

    public static void main(String[] args) {
        SpringApplication.run(SelfApplication.class, args);
    }

}

3.controller

@RestController
@RequestMapping("fb")
public class DemoController  {

    @RequestMapping(value="hl",method=RequestMethod.GET)
    public String sayHello(List<Long> ids) {
        return "hello";
    }
}

4.集成数据库

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
      <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.21</version>
        </dependency>
<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
项目启动类上添加标注
@MapperScan(value = "xxx.mapper", markerInterface = Mapper.class)


posted on 2020-04-04 00:43  杨杨09265  阅读(432)  评论(0编辑  收藏  举报