zoukankan      html  css  js  c++  java
  • spring boot 入门学习

    开始学习spring boot 相关知识,尝试建立web项目。

    首先建立一个空项目,然后进行配置相关文件

    Application代码如下:

    1 @SpringBootApplication
    2 public class Application {
    3 
    4     public static void main(String[] args) throws Exception {
    5         SpringApplication.run(Application.class, args);
    6     }
    7 
    8 }

    application我理解位程序入口,具体详细原理以后再学习

    Controller,控制器代码如下:

     1 @Controller  /*返回视图页名称*/
     2 //@RestController  返回json数据类型
     3 public class MainController {
     4 
     5     @RequestMapping("index")//连接访问名称
     6     public String index() {
     7         return "hello";//返回视图名称
     8     }
     9 
    10     @RequestMapping("hello")
    11     public String hello() {
    12         return "hello";
    13     }
    14 }

    application.yaml  配置文件,设置端口以及spring相关属性。

     1 debug: false
     2 
     3 server:
     4     port: 8080
     5 
     6 
     7 spring:
     8     http:
     9         encoding:
    10         charset: utf-8
    11         enabled: true
    12         force: true
    13     thymeleaf:
    14         mode: HTML5
    15         encoding: UTF-8
    16         content-type: text/html
    17         cache: false
    18         prefix: classpath:/templates/
    19         suffix: .html
    20     resources:
    21         static-locations: classpath:/static/

    pom的配置文件就不详细说明了  ,根据需要进行配置。

    这里说明SpringBoot的配置代码

     1 <parent>
     2     <groupId>org.springframework.boot</groupId>
     3     <artifactId>spring-boot-starter-parent</artifactId>
     4     <version>1.5.9.RELEASE</version>
     5 </parent>
     6 <dependencies>
     7     <dependency>
     8         <groupId>org.springframework.boot</groupId>
     9         <artifactId>spring-boot-starter-web</artifactId>
    10     </dependency>
    11 </dependencies>

    over

  • 相关阅读:
    css的网页布局案例
    position定位及实际应用
    float浮动以及案例演示
    第二十三节 margin合并实例
    第二十二节 margin合并
    第二十一节 margin技巧
    第二十节 盒子练习
    第十九节 盒子真实尺寸
    第十八节 盒子案例
    第十七节 盒子模型
  • 原文地址:https://www.cnblogs.com/yishilin/p/8302300.html
Copyright © 2011-2022 走看看