zoukankan      html  css  js  c++  java
  • Spring boot教程

    1.首先是新建Maven工程
    2.引入Pom依赖
    3.新建一个Controller
    4.运行Main方法
    5.浏览器访问

    pom.xml

    
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.rsc.spring</groupId>
      <artifactId>boot</artifactId>
      <packaging>war</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>boot Maven Webapp</name>
      <url>http://maven.apache.org</url>
    
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
      </properties>
    
      <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.5.RELEASE</version>
      </parent>
    
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
        </dependency>
    
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
    
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
              <source>1.7</source>
              <target>1.7</target>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </project>
    

    BaseController

    package com.rsc.spring.controller;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import org.springframework.web.bind.annotation.RestController;
    
    /**
     * Created by 58 on 2015/8/18.
     */
    @RestController
    @EnableAutoConfiguration
    public class BaceController {
    
        @RequestMapping("home")
        @ResponseBody
        public String home(){
            return "hello world My love boot";
        }
    
        public static void main(String[] args) {
            SpringApplication.run(BaceController.class,args);
        }
    
    
    }
    
    
  • 相关阅读:
    bootstrap图片上传功能
    Microsoft.EntityFrameworkCore.Sqlite的学习
    问题(待完成):微服务,失败回滚?保持事务的原子性?多步骤调用,如何来实现
    c# 重试机制
    .net core 问题:413 Request Entity Too Large nginx
    Validation
    Tag Helpers in forms in ASP.NET Core
    C/C++中如何获取数组的长度(宏&模板)
    斐波那契数列的实现
    PAT (Basic Level) Practise
  • 原文地址:https://www.cnblogs.com/ae6623/p/4740808.html
Copyright © 2011-2022 走看看