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);
        }
    
    
    }
    
    
  • 相关阅读:

    80老婆如何制服老公的
    男人三件事
    抄袭了一篇散文,很适合现在的我.
    讲个小笑话
    博客的性别???测试下!!!
    十八禁 大全 [转载]
    [转载]男人你没房没车,我凭什么嫁给你!
    电脑维修 小产业高利润
    一美女莫名晕倒 被七男强行拖入森林
  • 原文地址:https://www.cnblogs.com/ae6623/p/4740808.html
Copyright © 2011-2022 走看看