maven版SpringBoot的Hello World

maven版Hello World:
馬克- to-win:馬克 java社區(qū):防盜版實(shí)名手機(jī)尾號(hào): 73203。



1)馬克-to-win@馬克java社區(qū):新建maven項(xiàng)目,package方式為jar. 用archetype quick start.參考我視頻目錄下的SpringbootMaven項(xiàng)目。

2.在pom文件配置文件如下(除了測試,已經(jīng)是最小化的了):


<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com</groupId>
  <artifactId>mavenBoot</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>mavenBoot</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

     <parent>
        <groupId>org.springframework.boot</groupId>
(購買完整教程)

        <version>1.3.4.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    </dependencies>
</project>





package com;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
//@EnableAutoConfiguration
@SpringBootApplication
public class App {

    @RequestMapping("/hello")
    @ResponseBody
    String myhome() {
        return "spring boot maven版  馬克-to-win!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(App.class, args);
        //運(yùn)行之后在瀏覽器中訪問:http://localhost:8080/hello
     }
}

運(yùn)行結(jié)果: