博客
关于我
《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/

你可能感兴趣的文章
MyPython
查看>>
MTD技术介绍
查看>>
MySQL
查看>>
MySQL
查看>>
mysql
查看>>
MTK Android 如何获取系统权限
查看>>
MySQL - 4种基本索引、聚簇索引和非聚索引、索引失效情况、SQL 优化
查看>>
MySQL - ERROR 1406
查看>>
mysql - 视图
查看>>
MySQL - 解读MySQL事务与锁机制
查看>>
MTTR、MTBF、MTTF的大白话理解
查看>>
mt_rand
查看>>
mysql /*! 50100 ... */ 条件编译
查看>>
mudbox卸载/完美解决安装失败/如何彻底卸载清除干净mudbox各种残留注册表和文件的方法...
查看>>
mysql 1264_关于mysql 出现 1264 Out of range value for column 错误的解决办法
查看>>
mysql 1593_Linux高可用(HA)之MySQL主从复制中出现1593错误码的低级错误
查看>>
mysql 5.6 修改端口_mysql5.6.24怎么修改端口号
查看>>
MySQL 8.0 恢复孤立文件每表ibd文件
查看>>
MySQL 8.0开始Group by不再排序
查看>>
mysql ansi nulls_SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 什么意思
查看>>