spring boot入门
来源:互联网 发布:上海企业网络光纤宽带 编辑:程序博客网 时间:2024/05/03 01:02
依赖包需要maven构建工具或gradle
starter模块,spring boot的启动器:一系列的依赖包组合
1,spring boot应用启动的核心启动器,包含了自动配置,日志和yaml
2,spring-boot-starter-actuator,帮助监控和管理应用。
3,spring-boot-starter-amqp,通过spring-rabbit来支持AMQP协议(Advanced Message Queuing Protocol)
4,spring-boot-starter-aop,支持面向方面的编程即AOP,包括spring-aop和AspectJ
5,spring-boot-starter-artemis,通过Apache Artemis支持JMS的API(Java Message Service API)
6,spring-boot-starter-batch,支持Spring Batch,包括HSQLDB数据库
7,spring-boot-starter-cache,支持Spring的Cache抽象。
8,spring-boot-starter-cloud-connectors,支持Spring Cloud Connectors,简化了在像Cloud Foundry或Heroku这样的云平台上连接服务
9,spring-boot-starter-data-elasticsearch,支持ElasticSearch搜索和分析引擎,包括spring-data-elasticsearch。
10,spring-boot-starter-data-gemfire ,支持GemFire分布式数据存储,包括spring-data-gemfire。
11,spring-boot-starter-data-jpa,支持JPA(Java Persistence API),包括spring-data-jpa、spring-orm、hibernate。
12,spring-boot-starter-data-MongoDB,支持MongoDB数据,包括spring-data-mongodb。
13,spring-boot-starter-data-rest,通过spring-data-rest-webmvc,支持通过REST暴露Spring Data数据仓库
14,spring-boot-starter-data-solr,支持Apache Solr搜索平台,包括spring-data-solr。
15,spring-boot-starter-freemarker,支持FreeMarker模板引擎。
16,spring-boot-starter-groovy-templates,支持Groovy模板引擎。
17,spring-boot-starter-hateoas,通过spring-hateoas支持基于HATEOAS的RESTful Web服务。
18,spring-boot-starter-hornetq,通过HornetQ支持JMS。
19,spring-boot-starter-integration,支持通用的spring-integration模块。
20,spring-boot-starter-jdbc,支持JDBC数据库。
21,spring-boot-starter-jersey,支持Jersey RESTful Web服务框架。
22,spring-boot-starter-jta-atomikos,通过Atomikos支持JTA分布式事务处理。
23,spring-boot-starter-jta-bitronix,通过Bitronix支持JTA分布式事务处理。
24,spring-boot-starter-mail,支持javax.mail模块。
25,spring-boot-starter-mobile,支持spring-mobile。
26,spring-boot-starter-mustache,支持Mustache模板引擎。
27,spring-boot-starter-Redis,支持Redis键值存储数据库,包括spring-redis。
28,spring-boot-starter-security,支持spring-security。
29,spring-boot-starter-social-facebook,支持spring-social-facebook
30,spring-boot-starter-social-linkedin,支持pring-social-linkedin
31,spring-boot-starter-social-twitter,支持pring-social-twitter
32,spring-boot-starter-test,支持常规的测试依赖,包括JUnit、Hamcrest、Mockito以及spring-test模块。
33,spring-boot-starter-thymeleaf,支持Thymeleaf模板引擎,包括与Spring的集成。
34,spring-boot-starter-velocity,支持Velocity模板引擎。
35,spring-boot-starter-web,支持全栈式Web开发,包括Tomcat和spring-webmvc。
36,spring-boot-starter-websocket,支持WebSocket开发。
37,spring-boot-starter-ws,支持Spring Web Services。
Spring Boot应用启动器面向生产环境的还有2种,具体如下:
1)spring-boot-starter-actuator
增加了面向产品上线相关的功能,比如测量和监控。
2)spring-boot-starter-remote-shell
增加了远程ssh shell的支持。
最后,Spring Boot应用启动器还有一些替换技术的启动器,具体如下:
1)spring-boot-starter-jetty
引入了Jetty HTTP引擎(用于替换Tomcat)。
2)spring-boot-starter-log4j
支持Log4J日志框架。
3)spring-boot-starter-logging
引入了Spring Boot默认的日志框架Logback。
4)spring-boot-starter-tomcat
引入了Spring Boot默认的HTTP引擎Tomcat。
5)spring-boot-starter-undertow
引入了Undertow HTTP引擎(用于替换Tomcat)。
注意:
如果用maven时项目中有了parent属性,则使用import导入
注解:
@EnableAutoConfiguration 自动配置环境
SpringApplication 根据classpath创建合适的applicationContext实例
注册CommandLinePropertySource,将命令行参数作为spring propertis
加载所有单例bean
激活所有commandLineRunner beans
@SpringBootApplication 等同于默认的属性的 @Configuration, @EnableAutoConfiguration and @ComponentScan。
-- 注意,@ComponentScan 不能凭空使用。
<!--热部署--><dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.5.RELEASE</version></dependency>
通过mvn spring-boot:run
启动就支持热部署了
@ComponentScan告诉Spring 哪个packages 的用注解标识的类 会被spring自动扫描并且装入bean容器。
例如,如果你有个类用@Controller注解标识了,那么,如果不加上@ComponentScan,自动扫描该controller,那么该Controller就不会被spring扫描到,更不会装入spring容器中,因此你配置的这个Controller也没有意义。
类上的注解@Configuration 是最新的用注解配置spring,也就是说这是个配置文件,和原来xml配置是等效的
ComponentScan注解会告知Spring扫描指定的包来初始化SpringBean,这能够确保我们声明的Bean能够被发现。EnableAutoConfiguration将会启动自动配置模式,在我们的配置中会将对Tomcat的依赖级联进来,因此在应用启动时将会自动启动一个嵌入式的Tomcat,因为在样例中使用了SpringMVC,所以也会自动注册所需的DispatcherServlet,这都不需要类似web.xml这样的配置
请注意@EnableConfigurationProperties
注解。 这个注解告诉Spring Boot 使能支持@ConfigurationProperties,
@ConfigurationProperties
beans 被添加 – 用@Configuration
或者@Component
注解, 这样就可以在 component scan时候被发现了。
//设置事务@Beanpublic PlatformTransactionManager transactionManager() { return new DataSourceTransactionManager(dataSource());}
一旦 Spring 的 PlatformTransactionManager 配置好了,你可以在 Spring 中以你通常的做 法来配置事务。@Transactional 注解和 AOP(Aspect-Oriented Program,面向切面编程,译 者注)样式的配置都是支持的。在事务处理期间,一个单独的 SqlSession 对象将会被创建 和使用。当事务完成时,这个 session 会以合适的方式提交或回滚。
- 【Spring Boot】Spring Boot 入门
- Spring Boot 快速入门
- spring boot 入门
- Spring Boot 入门
- Spring Boot 入门
- spring boot简易入门
- Spring boot入门
- Spring Boot 快速入门
- Spring boot快速入门
- Spring boot 入门 实例
- Spring Boot 快速入门
- spring boot入门(一)
- spring boot入门例
- Spring Boot入门例子
- spring boot 入门
- Spring Boot入门
- Spring Boot 快速入门
- Spring Boot 入门笔记
- js调用打印接口打印web页面之——使用lodop组件打印jsp web页面
- C语言实验——图形输出(字符常量练习)(sdut oj)
- guava中对字符串进行分割
- Android百分制透明度转十六进制的C#windows小工具
- 嵌入式Linux学习:u-boot源码分析(1)--AM335X系列的2014.10版
- spring boot入门
- 按键:0~99加减
- 密码锁
- 可调时钟
- 蓝桥杯-基础练习 特殊回文数
- Gstreamer架构理解
- 数据库定期备份
- node.js第四天
- git学习笔记二(分支管理)