spring_boot攻略1.1-hello SpringBoot
Posted 程序也疯狂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring_boot攻略1.1-hello SpringBoot相关的知识,希望对你有一定的参考价值。
交流账号:2318645572
说明:
开发工具:eclipse
开发系统:windows 7
开发规范:maven项目
注意:按照我说的方式做下去
1.导包: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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cn.tedu</groupId> <artifactId>springboot2</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name> springboot2</name> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.3.RELEASE</version><!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.3.3.RELEASE</version> <classifier>sources</classifier> </dependency> </dependencies> </project>
2.创建application.java
package controller; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
3.创建HelloSpringBoot.java
package controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloSpringBoot {
@RequestMapping(value = "/")
String index(){
return "Hello Spring Boot!";
}
@RequestMapping(value="/back")
String demo1(){
return "jjjjj";
}
}
4.启动Application.java
可以在debug中右键启动
5,验收
打开浏览器,输入http://localhost:8080/
以上是关于spring_boot攻略1.1-hello SpringBoot的主要内容,如果未能解决你的问题,请参考以下文章