博客
关于我
《springboot学习笔记 01》--打印helloworld
阅读量:231 次
发布时间:2019-02-28

本文共 1269 字,大约阅读时间需要 4 分钟。

一, 基础项目搭建

1, 新建一普通maven项目(C:\work\workspace\a-sptingboot-test)

2, pom.xml配置

org.springframework.boot
spring-boot-starter-parent
1.4.4.RELEASE
org.springframework.boot
spring-boot-starter-web

3, 新建测试类, 直接run as启动

启动后, 出现Spring标识且无报错信息即ok

至此, Springboot基础项目搭建完成!!!

PS: 如若出现默认的8080端口冲突, 一个办法是关闭对应的服务(在此不做赘述), 一个是修改springboot默认端口

修改springboot默认端口(两种方法任选其一):

方法1: 实现EmbeddedServletContainerCustomizer接口, 重写对应方法设置默认端口

方法2: 配置application.propertie设置默认端口

server.port=8081

 

 

二, 通过浏览器访问应用

1, 配置spring-mvc.xml

2, 配置web.xml

springboot-test
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:conf/spring-mvc.xml
springboot-test
/

3, 写Controller

@RestControllerpublic class HelloWorldController {		@RequestMapping("hello")	public String info() {		return "Hello world!";	}}

4, 启动测试

4.1 启动之前编写的引导类Demo.java

4.2 测试访问

, 能正确打印 Hello world 即ok

PS: 实现修改java代码实时生效, 需要进行热部署配置( pom.xml )

org.springframework.boot
spring-boot-devtools

 

 

 

 

 

 

转载地址:http://dwip.baihongyu.com/

你可能感兴趣的文章
MySQL查询优化之索引
查看>>
mysql查询储存过程,函数,触发过程
查看>>
mysql查询总成绩的前3名学生信息
查看>>
mysql查询慢排查
查看>>
MySQL查询报错ERROR:No query specified
查看>>
mysql查询数据库储存数据的占用容量大小
查看>>
MySQL查询数据库所有表名及其注释
查看>>
MySQL查询数据表中数据记录(包括多表查询)
查看>>
MySQL查询结果排序
查看>>
MYSQL查询语句优化
查看>>
mysql查询语句能否让一个字段不显示出来_天天写order by,你知道Mysql底层执行原理吗?
查看>>
MySQL查询语句:揭秘专家秘籍,让你秒变数据库达人!
查看>>
mysql查询超时对PHP执行的影响
查看>>
mysql查询输出到excel文件_如何保存mysql查询输出到excel或.txt文件?
查看>>
mysql查询过程
查看>>
MySQL模拟Oracle序列sequence
查看>>
Mysql模糊查询like效率,以及更高效的写法
查看>>
MySQL死锁套路:一次诡异的批量插入死锁问题分析
查看>>
Mysql死锁问题Deadlock found when trying to get lock;try restarting transaction
查看>>
mysql每个数据库的最大连接数_MySQL数据库最大连接数
查看>>