Spring Boot 的 Hello World
来源:互联网 发布:怎样查看淘宝账号等级 编辑:程序博客网 时间:2024/05/20 09:44
Spring Boot 的 Hello World
最近微服务的概念在IT界炒的有点火,笔者按捺不住,也来凑凑热闹,储备技能,废话不多说,上教程,高手勿喷,纯粹学习入门随笔记录。
首先新建一个maven工程:
maven是一个好的工程构建工具,帮我们管理复杂的jar依赖关系,而Spring boot也充分利用maven的优点。
首先亮pom.xml:
首先新建一个maven工程:
maven是一个好的工程构建工具,帮我们管理复杂的jar依赖关系,而Spring boot也充分利用maven的优点。
首先亮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>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.3.1.RELEASE</version></parent><groupId>org.hxb</groupId><artifactId>Hello</artifactId><version>0.0.1-SNAPSHOT</version><dependencies><!--web应用基本环境配置 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>新建一个SampleController.java:
package org.hxb;import org.springframework.boot.test.SpringApplicationConfiguration;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;@Controller@SpringApplicationConfigurationpublic class SampleController {@RequestMapping(value="/")@ResponseBodyString home(){return "hello world!";}}
启动类Application.java:package org.hxb;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.context.annotation.ComponentScan;@ComponentScan(basePackages={"org.hxb"})@EnableAutoConfigurationpublic class Application {public static void main(String[] args) {SpringApplication.run(Application.class,args);}}
application.properties:
server.compression.enabled=trueserver.compression.min-response-size=1server.port=8081在打开cmd,进入项目根目录,执行命令:mvn spring-boot:run便可以启动。 在浏览器访问:http://localhost:8081/
1 0
- Spring Boot 的 Hello World
- spring-boot-hello-world
- spring-boot Hello World
- hello World Spring Boot
- spring boot 之 hello world !
- Spring Boot:简单Hello World
- Spring Boot 之Hello World
- spring boot(1)-Hello World
- spring boot之Hello World
- Spring-boot 第一章 hello world
- Spring Boot之Hello World
- Spring boot (一) Hello World
- spring-boot 之 Hello World
- Spring boot使用 hello world
- Spring boot (Hello World 级别)
- Spring Boot(hello world)
- Spring Boot之Hello World
- Spring-boot搭建一个简单的Hello World工程
- android 网络数据请求步骤 一 异步操作 AsyncTask
- java基础 JAVAString StringBuffer StringBuilder
- C++学习第二课
- json解析
- Eclipse和PyDev搭建完美Python开发环境(Windows篇)
- Spring Boot 的 Hello World
- Spark Streaming-1:Spark Streaming编程指南
- 第二行代码第六章笔记
- js touch 点击滑动轮播 菜鸟级别能做的滑动给有需要的同学
- Android 之Service的本地绑定
- iOS - 本地存储
- css设置填充颜色的圆形和正方形
- iOS编码规范、命名规则
- ffmpeg处理视频与声音