SpringBoot(二):初识SpringBoot HelloWorld
2017-06-14 00:00
483 查看
废话不多说 直接丢代码
pom.xml文件配置
控制层配送
启动项目 run as Java Application
访问localhost:8080就可以看到hello world
这样我们第一个springboot hello world就搞定喽
demo地址:https://git.oschina.net/LevelCoder/demos
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> <parent> <groupId>com.levelcoder</groupId> <artifactId>demo-springboot</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>demo-springboot_2</artifactId> <properties> <!-- 声明项目配置依赖编码格式为 utf-8 --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- java jdk 版本声明 可变更 根据自己配置去匹配 --> <java.version>1.8</java.version> </properties> <dependencies> <!-- 对web开发的支持,包括tomcat,spring-webmvc --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.5.2.RELEASE</version> </dependency> <!-- spring boot核心,包括自动配置支持,日志和YAML --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>1.5.2.RELEASE</version> </dependency> </dependencies> <build> <plugins> <!-- spring boot maven插件,可以将项目打包成一个可执行的jar文件 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
控制层配送
package com.levelcoder.controller; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; /** * * 描述:SpringBoot 初识 * * 作者:LevelCoder * * 邮件:LevelCoder@126.com * * 日期:2017年5月30日 下午8:40:43 * * 参考文献:https://my.oschina.net/LevelCoder/blog/858348 * * 版本:V1.0 */ @Controller @EnableAutoConfiguration public class HelloWorldController { @RequestMapping(value="/") @ResponseBody String home(){ return "Hello World"; } public static void main(String[] args) { SpringApplication.run(HelloWorldController.class, args); } }
启动项目 run as Java Application
访问localhost:8080就可以看到hello world
这样我们第一个springboot hello world就搞定喽
demo地址:https://git.oschina.net/LevelCoder/demos
相关文章推荐
- spring boot 初试,springboot入门,springboot helloworld例子
- SpringBoot初识(一)——Hello,SpringBoot
- Spring Boot实践教程(一):Hello,world!
- SpringBoot HelloWorld实现
- springboot开发 第一个案例之hello,world!
- hello World Spring Boot
- springboot开发 第一个案例之hello,world!
- SpringBoot学习之hello world
- SpringBoot之简介及"HelloWorld"
- spring boot Hello World(新手入门)
- Spring Boot——2分钟构建spring web mvc REST风格HelloWorld
- springboot学习之---初识springboot
- 【我的小伙伴 一】 初识Springboot+我的第一个Springboot项目
- Spring Boot 之Hello SpringBoot
- 简单! springboot 项目,访问返回 Hello SpringBoot !
- spring-boot-hello-world
- SpringBoot构建微服务实战 之 Hello SpringBoot(二)
- Spring Boot Hello World (使用Eclipse IDE)
- SpringBoot Helloworld 测试 Maven项目