1. 快速搭建
1,打开浏览器,在地址栏输入http://start.spring.io
2,填写项目信息
3,点击生成项目
4,简单演示
新建maven项目
点击下一步
点击下一步
点击完成
复制下载下来的项目到新建项目中
1, 关闭特定的自动配置
使用@SpringBootApplication的exclude(除去,不包括)参数,例如,关闭自动配置数据源。
不然启动的时候可能会出现错误
错误信息如下:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
可以写如下图的测试方法,右键Run As-->java application运行,在浏览器里直接访问http://localhost:8080/就能看到页面显示hoan的字样子。