从0开始学springboot之Hello World
1.pom.xml预览
<?xml version="1.0" encoding="UTF-8"?>
<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.notnull</groupId>
<artifactId>community-service</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
2.创建SampleController.java
package com.notnull.communityserivce;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;
@RestController
@EnableAutoConfiguration
public class SampleController {
@RequestMapping(value = "/helloworld")
String helloWorld(){
return "Hello World";
}
}
3.创建Application.java [用于启动springboot应用]
package com.notnull.communityserivce;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan("com.notnull.communityservice")
public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class, args);
}
}
4.启动应用 && 打开浏览器访问
打开浏览器输入http://localhost:8080/helloworld
输出Hello World
Hello World 完结
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。