springboot学习日志(一)-- 简单项目搭建

挖坑中。。萌新一个,感受本身才开始了程序开发的道路,加油和努力学习中。。
以前多多少少学过也写过一写后台代码,粗糙到本身没法忍受。。因此下定决心好好学习。。若有错误或者很差的地方,还请你们指出,共同窗习。html

以前写过一些关于springmvc的程序,最近学到了springboot 感受爽多了。。
我是根据《Spring Boot实战》逐步学习的springboot
那么开始第一步的学习 --- springboot搭建mysql

本人使用的是springboot2 可是书上的是1.3 全部有了些不一样,不过问题不大 都差不太多web

开发工具:idea + maven
开发数据库:mysql
开发前段:bootstrapspring

一、maven配置sql

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.BUILD-SNAPSHOT</version>
        <relativePath/>
    </parent>
    <dependencies>
        <!--springboot 的开组服务开发智齿-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--springboot 测试服务-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--springboot thymeleaf页面模板使用-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!--springboot 热部署-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <!--springboot build方式-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

二、yml配置数据库

###系统配置
server:
  ##服务端口号
  port: 10201
  servlet:
    ##服务根路径
    context-path: /platform
### 平台自定义变量
spring:
  profiles:
    ##使用配置
    active: dev
  ##模板设置
  thymeleaf:
    prefix: classpath:/templates
    suffix: .html
    mode: LEGACYHTML5
    encoding: utf-8
    servlet:
      content-type: text/html
    cache: false

三、controller和html搭建bootstrap

@Controller
@RequestMapping("test")
public class TestController {

    @RequestMapping(value = "info", method = RequestMethod.GET)
    public String pageInfo(HttpServletRequest request) {
        return "/test/info";
    }
}

这里的 /test/info 是在resources:templates 下面建立test目录而后建立info.html进行编写springboot

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
hello world
</body>
</html>

而后访问链接http://127.0.0.1:10201/platform/test/info就能够获得页面了mvc

clipboard.png

感受超级方便。。。app

相关文章
相关标签/搜索