springboot入门
2016-07-27 15:43
435 查看
spring是我们最熟悉不过的框架,但是其各种xml文件配置过于繁琐复杂,很容易出错。
现在推广一个springboot框架,轻量级,方便。
步骤:(楼主用的lead2016)
1.建立一个maven项目
2.添加依赖,如下:
3.建一个java类 controller
4.直接run,输出如下:
然后打开浏览器直接输入http://localhost:8080/hello 结果:
现在推广一个springboot框架,轻量级,方便。
步骤:(楼主用的lead2016)
1.建立一个maven项目
2.添加依赖,如下:
<?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.springboot</groupId> <artifactId>test</artifactId> <version>1.0-SNAPSHOT</version> <!--parent--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.5.RELEASE</version> <relativePath/> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
3.建一个java类 controller
package springboot; 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; /** * Created by 28906 on 2016/7/27. */ @Controller @EnableAutoConfiguration public class springBootTest { @RequestMapping("/hello") @ResponseBody public String sayHello(){ return "Hello springboot!"; } public static void main(String args[]){ SpringApplication.run(springBootTest.class,args); } }
4.直接run,输出如下:
然后打开浏览器直接输入http://localhost:8080/hello 结果:
相关文章推荐
- JVM(一)java的执行概要
- Java RandomAccessFile用法
- 《疯狂JAVA讲义》缓存实例的不可变类
- javaWeb项目中到底什么是单例,多例
- JAVA的Random类(转)
- 孤傲苍狼 只为成功找方法,不为失败找借口! javaweb学习总结(十五)——JSP基础语法 任何语言都有自己的语法,JAVA中有,JSP虽然是在JAVA上的一种应用,但是依然有其自己扩充的语
- java判断字符是否乱码
- SpringMVC拦截器
- SpringMVC非注解的处理器适配器-HandlerAdapter
- RxJava(三)简单常用操作符
- myeclipse 10的破解以及运行run.bat错误或者双击立即消失的问题
- maven编译javafx找不到
- java 读取大文件
- eclipse中出现注意:此元素既未附加源代码也未附加 Javadoc,因此无法找到 Javadoc。的解决方法
- java工厂设计模式
- spring-boot+mybatis动态sql
- java正则表达式
- Java自学能学会吗?
- eclipse, Log4j配置(真心的详细~)
- 《疯狂JAVA讲义》不可变类