Takes an opinionated view of building production-ready Spring applications. Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible.
旨在简化创建产品级的 Spring应用和服务。Spring Boot 引导优先于配置,它可以让你避免繁杂的配置,尽可能的帮助你快速建站。
经过十多年的发展Spring家族已经壮大,要灵活使用Spring家族的产品已经变得有些困难,尤其是要维护一大堆的配置文件,在项目开发中令人头疼。Spring Boot解决了这个问题,并大大简化了我们的开发成本
其优点如下:
使用maven建立web项目,并参考官方文档进行版本选择和pom配置
添加parent后添加相关依赖不需要version
|
|
web工程的依赖,包括spring mvc tomcat等,spring boot会在需要时使用
|
|
用来在main方法中启动工程
|
|
|
|
运行main函数之后访问http://localhost:8080/即可看到结果
问题出现在我建立maven项目编写java代码的时候在默认包中写的application类,并没有建立包。这种做法让Spring Boot每次都会扫描默认类及下属的所有类,浪费大量时间。所以在启动时会报警告,启动不成功
Your Application
class should be placed in a specific package and not in the default (top-level) package. For example, put it in com.example
and place all your application code in this package or in sub-packages like com.example.foo
and com.example.bar
.
Placing your Application
class in the default package, i.e. directly in src/main/java
isn’t a good idea and it will almost certainly cause your application to fail to start. If you do so, you should see this warning:
|
|
原文:https://www.cnblogs.com/lijianming180/p/12247737.html