没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
SpringBoot
1.SpringBoot 介绍:
随着动态语言的流行(Ruby,Groovy,Scala,Node.js),Java 的开发显得格外的笨重:
繁多的配置,低下的开发效率,复杂的部署流程以及第三方技术集成难度大。
在上述环境下,SpringBoot 应运而生。它使用“习惯由于配置”的理念让项
目快速运行起来。使用 SpringBoot 很容易创建一个独立运行(运行 jar,内嵌 Servlet
容器)准生产级别的基于 Spring 框架的项目,使用 SpringBoot 可以不用或只需要
很少的 Spring 配置。
2. SpringBoot 核心特点:
(1) 可以以 jar 包的形式独立运行,运行一个 SpringBoot 项目只需通过 java -jar
xx.jar 来运行
(2) 内嵌 Servlet 容器,SpringBoot 可以选择 Tomcat,Jetty 或者 Undertow,这样
我们无须以 war 包形式部署项目
(3) 简化 Maven 配置,SpringBoot 提供了一系列的 starter pom 来简化 Maven
的依赖加载
(4) SpringBoot 会根据在类路径中的 jar 包,类,为 jar 包中的类自动配置 Bean,
这样就极大的减少了我们要使用的配置
(5) SpringBoot 提供了基于 http,ssh,telnet 对运行时的项目进行监控
(6) 不借助于代码生成来实现,而是通过条件注解来实现,这也是 Spring4.x 的新
特性,不需要任何的 xml 配置即可实现 Spring 的所有配置
3. 搭建第一个 SpringBoot 入门程序:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
改变 JDK 版本:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
4. @EnableAutoConfiguration:启用自动配置,该注解会使 SpringBoot 根据项
目依赖的 jar 包自动配置项目的配置项。例如:我们添加了 spring-boot-starter-web
的依赖,项目中也就会引入 SpringMVC 的依赖,Spring Boot 就会自动配置 Tomcat
和 SpringMVC。
Spring Boot 支持的自动配置如下:
7.全局配置文件
Spring Boot 项目使用一个全局的配置文件 application.properties 或者是 application.yml,在
resources 目录下或者类路径下的/config 下,一般我们放到 resources 下。
修改 tomcat 的端口为 8088:
server.port=8088
进入 DispatcherServlet 的规则为:*.html
server.context-path=/hello
# BANNER
banner.charset=UTF-8 # Banner file encoding.
banner.location=classpath:banner.txt # Banner file location.
banner.image.location=classpath:banner.gif # Banner image file
location (jpg/png can also be used).
banner.image.width= # Width of the banner image in chars (default
76)
banner.image.height= # Height of the banner image in chars
(default based on image height)
banner.image.margin= # Left hand image margin in chars (default
2)
banner.image.invert= # If images should be inverted for dark
terminal themes (default false)
# LOGGING
logging.config= # Location of the logging configuration file. For
instance `classpath:logback.xml` for Logback
logging.exception-conversion-word=%wEx # Conversion word used
when logging exceptions.
logging.file= # Log file name. For instance `myapp.log`
logging.level.*= # Log levels severity mapping. For instance
`logging.level.org.springframework=DEBUG`
logging.path= # Location of the log file. For instance `/var/log`
logging.pattern.console= # Appender pattern for output to the
console. Only supported with the default logback setup.
logging.pattern.file= # Appender pattern for output to the file.
Only supported with the default logback setup.
logging.pattern.level= # Appender pattern for log level
(default %5p). Only supported with the default logback setup.
logging.register-shutdown-hook=false # Register a shutdown hook
for the logging system when it is initialized.
# AOP
spring.aop.auto=true # Add @EnableAspectJAutoProxy.
spring.aop.proxy-target-class=false # Whether subclass-based
(CGLIB) proxies are to be created (true) as opposed to standard
Java interface-based proxies (false).
# IDENTITY (ContextIdApplicationContextInitializer)
spring.application.index= # Application index.
spring.application.name= # Application name.
# ADMIN (SpringApplicationAdminJmxAutoConfiguration)
spring.application.admin.enabled=false # Enable admin features
for the application.
spring.application.admin.jmx-
name=org.springframework.boot:type=Admin,name=SpringApplication #
JMX name of the application admin MBean.
# AUTO-CONFIGURATION
spring.autoconfigure.exclude= # Auto-configuration classes to
exclude.
# SPRING CORE
spring.beaninfo.ignore=true # Skip search of BeanInfo classes.
# SPRING CACHE (CacheProperties)
spring.cache.cache-names= # Comma-separated list of cache names
to create if supported by the underlying cache manager.
spring.cache.caffeine.spec= # The spec to use to create caches.
Check CaffeineSpec for more details on the spec format.
spring.cache.couchbase.expiration=0 # Entry expiration in
milliseconds. By default the entries never expire.
spring.cache.ehcache.config= # The location of the configuration
file to use to initialize EhCache.
spring.cache.guava.spec= # The spec to use to create caches.
Check CacheBuilderSpec for more details on the spec format.
spring.cache.infinispan.config= # The location of the
configuration file to use to initialize Infinispan.
spring.cache.jcache.config= # The location of the configuration
file to use to initialize the cache manager.
spring.cache.jcache.provider= # Fully qualified name of the
CachingProvider implementation to use to retrieve the JSR-107
compliant cache manager. Only needed if more than one JSR-107
implementation is available on the classpath.
剩余95页未读,继续阅读
周林深
- 粉丝: 54
- 资源: 290
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0