maven版SpringBoot的Hello World

maven版Hello World:
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。



1)马克-to-win@马克java社区:新建maven项目,package方式为jar. 用archetype quick start.参考我视频目录下的SpringbootMaven项目。

2.在pom文件配置文件如下(除了测试,已经是最小化的了):


<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);
        //运行之后在浏览器中访问:http://localhost:8080/hello
     }
}

运行结果: