admin 的所有文章

mybatis关于jdbc连接报错,5.5.62MySQL连接,出现com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure等问题解决方法

首先mysql连接的驱动在5.7版本及之前驱动是

com.mysql.jdbc.Driver

在8.0更新之后需要注意,已经换成了以下的需要加cj

om.mysql.cj.jdbc.Driver

如果出现com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure等问题首先检查jdbc的url是否正确,在8.0以上需要注意,有些参数已经被废弃但是必须的参数有以下

jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncodeing=UTF-8&useSSL=false&serverTimezone=GMT

连接的符号也从“&”换成”&“注意其他的符号在在xml文件中并不支持,有些参数已经被废弃,以上的都是在MySQL8.0版本出现的问题。

 

同时还需要检查驱动是否对应了版本号

参照地址:

https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-versions.html

Springboot集成JPA

1.Jpa的介绍与使用

 JPA(Java Persistence API)是Sun官方提出的Java持久化规范。它为Java开发人员提供了一种对象/关联映射工具来管理Java应用中的关系数据。他的出现主要是为了简化现有的持久化开发工作和整合ORM技术,结束现在Hibernate,TopLink,JDO等ORM框架各自为营的局面。值得注意的是,JPA是在充分吸收了现有Hibernate,TopLink,JDO等ORM框架的基础上发展而来的,具有易于使用,伸缩性强等优点。从目前的开发社区的反应上看,JPA受到了极大的支持和赞扬

注意:JPA是一套规范,不是一套产品,那么像Hibernate,TopLink,JDO他们是一套产品,如果说这些产品实现了这个JPA规范,那么我们就可以叫他们为JPA的实现产品。

Spring Data JPA 是 Spring 基于 ORM 框架、JPA 规范的基础上封装的一套JPA应用框架,可使开发者用极简的代码即可实现对数据的访问和操作。它提供了包括增删改查等在内的常用功能,且易于扩展!学习并使用 Spring Data JPA 可以极大提高开发效率!

使用时需要继承JpaRepository

2.JPA的基本查询—默认实现

 

3.Springboot集成JPA

 

 

 

  引入依赖

 <!-- mysql驱动 -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>
  <!-- springdata jpa依赖 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

修改配置文件

###数据源配置
########################################################
spring.datasource.url = jdbc:mysql://localhost:3306/springboot
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.max-active=20
spring.datasource.max-idle=8
spring.datasource.min-idle=8
spring.datasource.initial-size=10
########################################################
### 持久化配置
########################################################
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create、create-drop、update、validate、none)
#validate: 在每次项目启动的时候,会自动进行表结构与我们的实体类的验证,如果表结构与实体类的代码不相符,就会产生报错。
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
#[org.hibernate.cfg.ImprovedNamingStrategy              #org.hibernate.cfg.DefaultNamingStrategy]
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

  其中,spring.jpa.hibernate.ddl-auto 参数用来配置是否开启自动更新数据库表结构,可取create、create-drop、update、validate、none五个值。 create 每次加载hibernate时,先删除已存在的数据库表结构再重新生成;create-drop 每次加载hibernate时,先删除已存在的数据库表结构再重新生成,并且当 sessionFactory关闭时自动删除生成的数据库表结构;update 只在第一次加载hibernate时自动生成数据库表结构,以后再次加载hibernate时根据model类自动更新表结构;validate 每次加载hibernate时,验证数据库表结构,只会和数据库中的表进行比较,不会创建新表,但是会插入新值。none 关闭自动更新 

4.JPA的基本查询—方法名解析

 

 

 

 

 

 5.JPA的复杂查询-分页查询

分页查询在实际使用中非常普遍了,spring data jpa已经帮我们实现了分页的功能,在查询的方法中,需要传入参数Pageable ,当查询中有多个参数的时候Pageable建议做为最后一个参数传入Pageable 是spring封装的分页实现类,使用的时候需要传入页数、每页条数和排序规则

Page<User> findALL(Pageable pageable); 

Page<User> findByUserName(String userName,Pageable pageable);

6.JPA的复杂查询-限制查询

有时候我们只需要查询前N个元素,或者只取前一个实体。

User findFirstByOrderByAgeAsc();

User findTopByOrderByAgeDesc();

List<User> findFirst10ByAge(Integer age, Sort sort);

List<User> findTop10ByAge(Integer age, Pageable pageable);

7.自定义SQL查询

其实Spring data 觉大部分的SQL都可以根据方法名定义的方式来实现,但是由于某些原因我们想使用自定义的SQL来查询,spring data也是完美支持的;在SQL的查询方法上面使用@Query注解,如涉及到删除和修改在需要加上@Modifying.也可以根据需要添加 @Transactional 对事物的支持,查询超时的设置等

 

 

Springboot热部署配置

添加依赖包:

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
		</dependency>

编译配置里添加配置

<configuration>
<fork>true</fork>
</configuration>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<fork>true</fork>
				</configuration>
			</plugin>
		</plugins>
	</build>

  

Springboot集成Redis

Redis技术栈目前广泛使用于开发领域,掌握Redis技术栈与Springboot的集成至关重要。

Redis是目前业界使用最广泛的内存数据存储。相比memcached,Redis支持更丰富的数据结构,例如hashes, lists, sets等,同时支持数据持久化。除此之外,Redis还提供一些类数据库的特性,比如事务,HA,主从库。可以说Redis兼具了缓存系统和数据库的一些特性,因此有着丰富的应用场景。

1.安装redis

下载地址:https://github.com/MSOpenTech/redis/releases。
Redis 支持 32 位和 64 位。这个需要根据你系统平台的实际情况选择

 

 

 Redis的目录结构

 

 

 

 

*.conf:配置文件,配置redis的一些特征,如修改监听端口等。

Redis-server.exe : redis服务器启动文件。
	redis-server.exe redis.windows.conf

Redis-cli.exe : 客户端启动文件
	redis-cli.exe -h 127.0.0.1 -p 6379 –a password

Redis 命令参考网址 :

http://doc.redisfans.com/

2.Springboot集成Redis

  (1)引入spring-boot-starter-redis

 <dependency>

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

<--!进行redisTemplate配置的时候需要此jar包 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>

 

在springboot2之后,redis默认集成的是lettuce.

1.5的版本默认采用的连接池技术是jedis , 2.0以上版本默认连接池是lettuce.

1.5版本的springboot集成redis与2.0有所不同(核心配置类的书写也有很大的区别),主要是因为连接池技术使用的差异,这里主要介绍springboot的2.x版本。

Jedis与Lettuce的区别

如果你在网上搜索Redis 的Java客户端,你会发现,大多数文献介绍的都是 Jedis。

不可否认,Jedis是一个优秀的基于Java语言的Redis客户端。
但是,其不足也很明显:Jedis在实现上是直接连接Redis-Server,在多个线程间共享一个Jedis实例时是线程不安全的,如果想要在多线程场景下使用Jedis,需要使用连接池,每个线程都使用自己的Jedis实例,当连接数量增多时,会消耗较多的物理资源。

与Jedis相比,Lettuce则完全克服了其线程不安全的缺点:Lettuce是一个可伸缩的线程安全的Redis客户端,支持同步、异步和响应式模式。
多个线程可以共享一个连接实例,而不必担心多线程并发问题。
它基于优秀Netty NIO框架构建,支持Redis的高级功能,如Sentinel,集群,流水线,自动重新连接和Redis数据模型。

(2)添加配置文件

# REDIS (RedisProperties)
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=127.0.0.1
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=1000

(3)书写核心集成配置类(***)

 

  完整代码如下:

package config;

import java.time.Duration;

import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheManager.RedisCacheManagerBuilder;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;

//Redis的核心配置类,这个类提供了两个方法(其实提供了两个bean,这两个bean会加载到spring的context里边,供使用者进行调用)
@Configuration //这个标签,通常与@bean结合使用,当@bean使用到该类的方法上,代表将该方法做为一个bean交给了spring的context进行了管理。
@EnableCaching //允许使用我们的缓存cache
public class RedisConfig extends CachingConfigurerSupport{
	
	@Bean
	public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory){
		//自主实现我们的redisTemplate方法。
		RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
		//序列化
		StringRedisSerializer redisSerializer = new StringRedisSerializer();
		//引入json串的转换类
		Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = 
				new Jackson2JsonRedisSerializer(Object.class);
		
		ObjectMapper om = new ObjectMapper();
		om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
		om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
		jackson2JsonRedisSerializer.setObjectMapper(om);
		
		//redisTemplate设置
		redisTemplate.setConnectionFactory(factory);
		//redis key的序列化
		redisTemplate.setKeySerializer(redisSerializer);
		//value 序列化 使用的是jasonJackson2JsonRedisSerializer。我们的value大部分都是通过对象转化来的
		redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
		//value的序列化 hashmap的序列化
		redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
		return redisTemplate;
	}
	
	@Bean
	public CacheManager cacheManager(RedisConnectionFactory factory) {
		//序列化
		StringRedisSerializer redisSerializer = new StringRedisSerializer();
		//引入json串的转换类
		Jackson2JsonRedisSerializer jasonJackson2JsonRedisSerializer = 
				new Jackson2JsonRedisSerializer(Object.class);
		
		ObjectMapper om = new ObjectMapper();
		//设置我们的objectMapper的访问权限
		om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
		om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
		jasonJackson2JsonRedisSerializer.setObjectMapper(om);
		
		//序列化配置,乱码问题解决以及我们的缓存的时效性
		RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().
				entryTtl(Duration.ofSeconds(1000)).
				serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer)).
				serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jasonJackson2JsonRedisSerializer)).
				disableCachingNullValues();
		
		//RedisCacheManager cacheManager = RedisCacheManager.builder(factory).cacheDefaults(config).build();
		RedisCacheManager cacheManager = RedisCacheManagerBuilder.fromConnectionFactory(factory).cacheDefaults(config).build();
		
		return cacheManager;
	}

}

  

(4).springboot主配置类要加上@EnableCaching注解 

 

 

 (5).StringRedisTemplate与RedisTemplate区别点

两者的关系是StringRedisTemplate继承RedisTemplate。

两者的数据是不共通的;也就是说StringRedisTemplate只能管理StringRedisTemplate里面的数据,RedisTemplate只能管理RedisTemplate中的数据。

其实他们两者之间的区别主要在于他们使用的序列化类:
    RedisTemplate使用的是JdkSerializationRedisSerializer    存入数据会将数据先序列化成字	节数组然后在存入Redis数据库。 
      StringRedisTemplate使用的是StringRedisSerializer

使用时注意事项:
   当你的redis数据库里面本来存的是字符串数据或者你要存取的数据就是字符串类型数据	的时候,那么你就使用StringRedisTemplate即可。
   但是如果你的数据是复杂的对象类型,而取出的时候又不想做任何的数据转换,直接从	Redis里面取出一个对象,那么使用RedisTemplate是更好的选择。

  RedisTemplate常用操作

             redisTemplate.opsForValue();  //操作字符串
             redisTemplate.opsForHash();   //操作hash
             redisTemplate.opsForList();   //操作list
             redisTemplate.opsForSet();    //操作set
             redisTemplate.opsForZSet();   //操作有序set

  StringRedisTemplate常用操作

		stringRedisTemplate.opsForValue().set("test", "100",60*10,TimeUnit.SECONDS);//向redis里存入数据和设置缓存时间  
		stringRedisTemplate.boundValueOps("test").increment(-1);//val做-1操作
		stringRedisTemplate.opsForValue().get("test")//根据key获取缓存中的val
		stringRedisTemplate.boundValueOps("test").increment(1);//val +1
		stringRedisTemplate.getExpire("test")//根据key获取过期时间
		stringRedisTemplate.getExpire("test",TimeUnit.SECONDS)//根据key获取过期时间并换算成指定单位 
		stringRedisTemplate.delete("test");//根据key删除缓存
		stringRedisTemplate.hasKey("546545");//检查key是否存在,返回boolean值 
		stringRedisTemplate.opsForSet().add("red_123", "1","2","3");//向指定key中存放set集合
		stringRedisTemplate.expire("red_123",1000 , TimeUnit.MILLISECONDS);//设置过期时间
		stringRedisTemplate.opsForSet().isMember("red_123", "1")//根据key查看集合中是否存在指定数据
		stringRedisTemplate.opsForSet().members("red_123");//根据key获取set集合

(6).Redis技术栈练习

 

1.cacheManage的练习使用(***重点)

2.RedisTemplate 和 StringRedisTemplate的使用

package com.qyc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisController {
	
	@Autowired
	private RedisTemplate redisTemplate;
	
	@Autowired
	private StringRedisTemplate stringRedisTemplate;
	
	
	@RequestMapping("/getString")
	@Cacheable(value = "springboot",key="#root.methodName")// "springboot::getString"他成为了我们的在redis里边的key
	public String getString() {
		//1.对于我们的这个value属性来说,它代表的是一块内存区域(例子:类似于我们的d盘,C盘,这时候springboot代表了就是我们的
		//不同区域的存储空间划分
		//2.代表key。这个key是属于springboot这个缓存区域的key
		//3.(当笑话听,主要为让同学更加理解)总结:将我们的内存区域分了一块出来,取名springboot,然后我们将getString这个key存入到了这个springboot磁盘区)
		String string = "Hello world!";
		//这个sysout会不会每次都打印呢?不会,因为第一次进行helloworld返回的时候,就已经将我们的string存入到了
		//我们的redis缓存中,在30s内进行该方法的访问时,不会走正常的逻辑,而是会走 @Cacheable 的内部实现逻辑
		//也就是说,sysout之后的代码不会被执行到。方便啊,真方便啊
		System.out.println("如果打印这条信息,代表我们的返回值是没有从缓存里边取出的");
		return string;
	}

	/**
	 * redisTemplate & stringRedisTemplate
	 */
	@PostMapping("/set")
	public void set() {
		redisTemplate.opsForValue().set("myName","zhangsan");
		stringRedisTemplate.opsForValue().set("youName", "LiSi");
	}
	
	@GetMapping("/get")
	public void get() {
		String myname = (String)redisTemplate.opsForValue().get("myName");
		String youName = (String)redisTemplate.opsForValue().get("youName");
		String youName1 = stringRedisTemplate.opsForValue().get("youName");
		System.out.println("myname:"+ myname);
		System.out.println("youName:"+ youName);//没有获取到值,说明两者的数据是不共通的
		System.out.println("youName1:"+ youName1);
	}
}

  

 

 

上图中key的说明:

 

Springboot默认配置文件application.properties的常见配置属性

#SPRING CONFIG(ConfigFileApplicationListener)  
spring.config.name =#配置文件名(默认 为  'application' )  
spring.config.location =#配置文件的位置  
 
# 多环境配置文件激活属性
spring.profiles.active=dev					#加载application-dev.properties配置文件内容 
application-dev.properties:					#开发环境
application-test.properties:					#测试环境
application-prod.properties:					#生产环境
 
 
#activemq
spring.activemq.broker-url						#指定ActiveMQ broker的URL,默认自动生成.
spring.activemq.in-memory						#是否是内存模式,默认为true.
spring.activemq.password						#指定broker的密码.
spring.activemq.pooled							#是否创建PooledConnectionFactory,而非ConnectionFactory,默认false
spring.activemq.user							#指定broker的用户.
 
 
#aop
spring.aop.auto									#是否支持@EnableAspectJAutoProxy,默认为: true
spring.aop.proxy-target-class					#true为使用CGLIB代理,false为JDK代理,默认为false
 
 
#application
spring.application.admin.enabled				#是否启用admin特性,默认为: false
spring.application.admin.jmx-name				#指定admin MBean的名称,默认为: org.springframework.boot:type=Admin,name=SpringApplication
 
 
#artemis(HornetQ捐献给apache后的版本)
spring.artemis.embedded.cluster-password		#指定集群的密码,默认是启动时随机生成.
spring.artemis.embedded.data-directory			#指定Journal文件的目录.如果不开始持久化则不必要指定.
spring.artemis.embedded.enabled					#是否开启内嵌模式,默认true
spring.artemis.embedded.persistent				#是否开启persistent store,默认false.
spring.artemis.embedded.queues					#指定启动时创建的队列,多个用逗号分隔,默认: []
spring.artemis.embedded.server-id				#指定Server ID. 默认是一个自增的数字,从0开始.
spring.artemis.embedded.topics					#指定启动时创建的topic,多个的话逗号分隔,默认: []
spring.artemis.host								#指定Artemis broker 的host. 默认: localhost
spring.artemis.mode								#指定Artemis 的部署模式, 默认为auto-detected(也可以为native or embedded).
spring.artemis.port								#指定Artemis broker 的端口,默认为: 61616
 
 
#autoconfig
spring.autoconfigure.exclude					#配置要排除的Auto-configuration classes.
 
 
#batch
spring.batch.initializer.enabled				#是否在必要时创建batch表,默认为true
spring.batch.job.enabled						#是否在启动时开启batch job,默认为true
spring.batch.job.names							#指定启动时要执行的job的名称,逗号分隔,默认所有job都会被执行
spring.batch.schema								#指定要初始化的sql语句路径,默认:classpath:org/springframework/batch/core/schema-@@platform@@.sql)
spring.batch.table-prefix						#指定批量处理的表的前缀.
 
 
#cookie、session配置
server.session.cookie.comment					#指定session cookie的comment
server.session.cookie.domain					#指定session cookie的domain
server.session.cookie.http-only					#是否开启HttpOnly.
server.session.cookie.max-age					#设定session cookie的最大age.
server.session.cookie.name						#设定Session cookie 的名称.
server.session.cookie.path						#设定session cookie的路径.
server.session.cookie.secure					#设定session cookie的“Secure” flag.
server.session.persistent						#重启时是否持久化session,默认false
server.session.timeout							#session的超时时间
server.session.tracking-modes					#设定Session的追踪模式(cookie, url, ssl).
 
 
#datasource 
spring.dao.exceptiontranslation.enabled			#是否开启PersistenceExceptionTranslationPostProcessor,默认为true
spring.datasource.abandon-when-percentage-full	#设定超时被废弃的连接占到多少比例时要被关闭或上报
spring.datasource.allow-pool-suspension			#使用Hikari pool时,是否允许连接池暂停,默认为: false
spring.datasource.alternate-username-allowed	#是否允许替代的用户名.
spring.datasource.auto-commit					#指定updates是否自动提交.
spring.datasource.catalog						#指定默认的catalog.
spring.datasource.commit-on-return				#设置当连接被归还时,是否要提交所有还未完成的事务
spring.datasource.connection-init-sql			#指定连接被创建,再被添加到连接池之前执行的sql.
spring.datasource.connection-init-sqls			#使用DBCP connection pool时,指定初始化时要执行的sql
spring.datasource.connection-properties.[key]	#在使用DBCP connection pool时指定要配置的属性
spring.datasource.connection-test-query			#指定校验连接合法性执行的sql语句
spring.datasource.connection-timeout			#指定连接的超时时间,毫秒单位.
spring.datasource.continue-on-error				#在初始化数据库时,遇到错误是否继续,默认false
spring.datasource.data							#指定Data (DML)脚本
spring.datasource.data-source-class-name		#指定数据源的全限定名.
spring.datasource.data-source-jndi				#指定jndi的地址
spring.datasource.data-source-properties.[key]	#使用Hikari connection pool时,指定要设置的属性
spring.datasource.db-properties					#使用Tomcat connection pool,指定要设置的属性
spring.datasource.default-auto-commit			#是否自动提交.
spring.datasource.default-catalog				#指定连接默认的catalog.
spring.datasource.default-read-only				#是否设置默认连接只读.
spring.datasource.default-transaction-isolation	#指定连接的事务的默认隔离级别.
spring.datasource.driver-class-name				#指定driver的类名,默认从jdbc url中自动探测.
spring.datasource.fair-queue					#是否采用FIFO返回连接.
spring.datasource.health-check-properties.[key]	#使用Hikari connection pool时,在心跳检查时传递的属性
spring.datasource.idle-timeout					#指定连接多久没被使用时,被设置为空闲,默认为10ms
spring.datasource.ignore-exception-on-pre-load	#当初始化连接池时,是否忽略异常.
spring.datasource.init-sql						#当连接创建时,执行的sql
spring.datasource.initial-size					#指定启动连接池时,初始建立的连接数量
spring.datasource.initialization-fail-fast		#当创建连接池时,没法创建指定最小连接数量是否抛异常
spring.datasource.initialize					#指定初始化数据源,是否用data.sql来初始化,默认: true
spring.datasource.isolate-internal-queries		#指定内部查询是否要被隔离,默认为false
spring.datasource.jdbc-interceptors				#使用Tomcat connection pool时,指定jdbc拦截器,分号分隔
spring.datasource.jdbc-url						#指定JDBC URL.
spring.datasource.jmx-enabled					#是否开启JMX,默认为: false
spring.datasource.jndi-name						#指定jndi的名称.
spring.datasource.leak-detection-threshold		#使用Hikari connection pool时,多少毫秒检测一次连接泄露.
spring.datasource.log-abandoned					#使用DBCP connection pool,是否追踪废弃statement或连接,默认为: false
spring.datasource.log-validation-errors			#当使用Tomcat connection pool是否打印校验错误.
spring.datasource.login-timeout					#指定连接数据库的超时时间.
spring.datasource.max-active					#指定连接池中最大的活跃连接数.
spring.datasource.max-age						#指定连接池中连接的最大年龄
spring.datasource.max-idle						#指定连接池最大的空闲连接数量.
spring.datasource.max-lifetime					#指定连接池中连接的最大生存时间,毫秒单位.
spring.datasource.max-open-prepared-statements	#指定最大的打开的prepared statements数量.
spring.datasource.max-wait						#指定连接池等待连接返回的最大等待时间,毫秒单位.
spring.datasource.maximum-pool-size				#指定连接池最大的连接数,包括使用中的和空闲的连接.
spring.datasource.min-evictable-idle-time-millis		#指定一个空闲连接最少空闲多久后可被清除.
spring.datasource.min-idle						#指定必须保持连接的最小值(For DBCP and Tomcat connection pools)
spring.datasource.minimum-idle					#指定连接维护的最小空闲连接数,当使用HikariCP时指定.
spring.datasource.name							#指定数据源名.
spring.datasource.num-tests-per-eviction-run	#指定运行每个idle object evictor线程时的对象数量
spring.datasource.password						#指定数据库密码.
spring.datasource.platform						#指定schema要使用的Platform(schema-${platform}.sql),默认为: all
spring.datasource.pool-name						#指定连接池名字.
spring.datasource.pool-prepared-statements		#指定是否池化statements.
spring.datasource.propagate-interrupt-state		#在等待连接时,如果线程被中断,是否传播中断状态.
spring.datasource.read-only						#当使用Hikari connection pool时,是否标记数据源只读
spring.datasource.register-mbeans				#指定Hikari connection pool是否注册JMX MBeans.
spring.datasource.remove-abandoned				#指定当连接超过废弃超时时间时,是否立刻删除该连接.
spring.datasource.remove-abandoned-timeout		#指定连接应该被废弃的时间.
spring.datasource.rollback-on-return			#在归还连接时,是否回滚等待中的事务.
spring.datasource.schema						#指定Schema (DDL)脚本.
spring.datasource.separator						#指定初始化脚本的语句分隔符,默认: ;
spring.datasource.sql-script-encoding			#指定SQL scripts编码.
spring.datasource.suspect-timeout				#指定打印废弃连接前的超时时间.
spring.datasource.test-on-borrow				#当从连接池借用连接时,是否测试该连接.
spring.datasource.test-on-connect				#创建时,是否测试连接
spring.datasource.test-on-return				#在连接归还到连接池时是否测试该连接.
spring.datasource.test-while-idle				#当连接空闲时,是否执行连接测试.
spring.datasource.time-between-eviction-runs-millis    #指定空闲连接检查、废弃连接清理、空闲连接池大小调整之间的操作时间间隔
spring.datasource.transaction-isolation			#指定事务隔离级别,使用Hikari connection pool时指定
spring.datasource.url							#指定JDBC URL.
spring.datasource.use-disposable-connection-facade		#是否对连接进行包装,防止连接关闭之后被使用.
spring.datasource.use-equals					#比较方法名时是否使用String.equals()替换==.
spring.datasource.use-lock						#是否对连接操作加锁
spring.datasource.username						#指定数据库名.
spring.datasource.validation-interval			#指定多少ms执行一次连接校验.
spring.datasource.validation-query				#指定获取连接时连接校验的sql查询语句.
spring.datasource.validation-query-timeout		#指定连接校验查询的超时时间.
spring.datasource.validation-timeout			#设定连接校验的超时时间,当使用Hikari connection pool时指定
spring.datasource.validator-class-name			#用来测试查询的validator全限定名.
spring.datasource.xa.data-source-class-name		#指定数据源的全限定名.
spring.datasource.xa.properties					#指定传递给XA data source的属性
#data  springdata
spring.data.elasticsearch.cluster-name			#指定es集群名称,默认: elasticsearch
spring.data.elasticsearch.cluster-nodes			#指定es的集群,逗号分隔,不指定的话,则启动client node.
spring.data.elasticsearch.properties			#指定要配置的es属性.
spring.data.elasticsearch.repositories.enabled	#是否开启es存储,默认为: true
spring.data.jpa.repositories.enabled			#是否开启JPA支持,默认为: true
spring.data.mongodb.authentication-database		#指定鉴权的数据库名
spring.data.mongodb.database					#指定mongodb数据库名
spring.data.mongodb.field-naming-strategy		#指定要使用的FieldNamingStrategy.
spring.data.mongodb.grid-fs-database			#指定GridFS database的名称.
spring.data.mongodb.host						#指定Mongo server host.
spring.data.mongodb.password					#指定Mongo server的密码.
spring.data.mongodb.port						#指定Mongo server port.
spring.data.mongodb.repositories.enabled		#是否开启mongodb存储,默认为true
spring.data.mongodb.uri							#指定Mongo database URI.默认:mongodb://localhost/test
spring.data.mongodb.username					#指定登陆mongodb的用户名.
spring.data.rest.base-path						#指定暴露资源的基准路径.
spring.data.rest.default-page-size				#指定每页的大小,默认为: 20
spring.data.rest.limit-param-name				#指定limit的参数名,默认为: size
spring.data.rest.max-page-size					#指定最大的页数,默认为1000
spring.data.rest.page-param-name				#指定分页的参数名,默认为: page
spring.data.rest.return-body-on-create			#当创建完实体之后,是否返回body,默认为false
spring.data.rest.return-body-on-update			#在更新完实体后,是否返回body,默认为false
spring.data.rest.sort-param-name				#指定排序使用的key,默认为: sort
spring.data.solr.host							#指定Solr host,如果有指定了zk的host的话,则忽略。默认为: http://127.0.0.1:8983/solr
spring.data.solr.repositories.enabled			#是否开启Solr repositories,默认为: true
spring.data.solr.zk-host						#指定zk的地址,格式为HOST:PORT.
#----------------------------------------  
#DEVTOOLS属性  
#----------------------------------------  
  
#DEVTOOLS(DevToolsProperties)  
spring.devtools.livereload.enabled = true		#启用livereload.com兼容的server。  
spring.devtools.livereload.port = 35729			#服务器端口。  
spring.devtools.restart.additional-exclude =		#应该从触发完全重新启动时排除的其他模式。  
spring.devtools.restart.additional-paths =		#额外的路径来观察变化。  
spring.devtools.restart.enabled = true			#启用自动重启。  
spring.devtools.restart.exclude = META-INF /行家/ **,META-INF /资源/ **,资源/ **,静态/ **,公共/ **,模板/ **,** / * Test.class,** / * Tests.class,git.properties#应该排除触发完全重启的模式。  
spring.devtools.restart.poll-interval = 1000	#polling 路径更改之间等待的时间(以毫秒为单位)。  
spring.devtools.restart.quiet-period = 400		#触发重新启动之前,没有任何类路径变化所需的静默时间(以毫秒为单位)。  
spring.devtools.restart.trigger-file =			#特定文件的名称,在更改时会触发重新启动检查。如果未指定任何类路径文件更改将触发重新启动。  
  
  
#DEVTOOLS   REMOTE DEVTOOLS(RemoteDevToolsProperties)  
spring.devtools.remote.context-path =  			#用于处理远程连接的上下文路径。  
spring.devtools.remote.debug.enabled = true		#启用远程调试支持。  
spring.devtools.remote.debug.local-port = 8000	#本地远程调试服务器端口。  
spring.devtools.remote.proxy.host =				#用于连接远程应用程序的代理主机。  
spring.devtools.remote.proxy.port =				#用于连接远程应用程序的代理端口。  
spring.devtools.remote.restart.enabled = true	#启用远程重启。  
spring.devtools.remote.secret =					#建立连接所需的共享密钥(需要启用远程支持)。  
spring.devtools.remote.secret-header-name = X-AUTH-TOKEN  		#用于传输共享密钥的HTTP头。  
 
 
#----------------------------------------  
#执行器属性  
#----------------------------------------  
  
#ENDPOINTS(AbstractEndpoint子类)  
endpoints.enabled = true						#启用端点。  
endpoints.sensitive =							#默认的端点敏感设置。  
endpoints.actuator.enabled = true				#启用端点。  
endpoints.actuator.path =						#端点URL路径。  
endpoints.actuator.sensitive = false			#在端点上启用安全性。  
endpoints.autoconfig.enabled =					#启用端点。  
endpoints.autoconfig.id =						#端点标识符。  
endpoints.autoconfig.sensitive =				#标记端点是否暴露敏感信息。  
endpoints.beans.enabled =						#启用端点。  
endpoints.beans.id =							#端点标识符。  
endpoints.beans.sensitive =						#标记端点是否暴露敏感信息。  
endpoints.configprops.enabled =					#启用端点。  
endpoints.configprops.id =						#端点标识符。  
endpoints.configprops.keys-to-sanitize			#应该清理的密钥。键可以是属性以或正则表达式结束的简单字符串。  
endpoints.configprops.sensitive =				#标记端点是否公开敏感信息。  
endpoints.docs.curies.enabled = false			#启用居里代。  
endpoints.docs.enabled = true					#启用执行器文档终结点。  
endpoints.docs.path = / docs					#  
endpoints.docs.sensitive = false				#  
 
  
#终端CORS配置(EndpointCorsProperties)  
endpoints.cors.allow-credentials =				#设置是否支持凭据。未设置时,不支持凭证。  
endpoints.cors.allowed-headers =				#在请求中允许使用逗号分隔的标题列表。'*'允许所有标题。  
endpoints.cors.allowed-methods = GET			#逗号分隔的允许的方法列表。'*'允许所有的方法。  
endpoints.cors.allowed-origins =				#逗号分隔的起源列表允许。'*'允许所有的来源。未设置时,CORS支持被禁用。  
endpoints.cors.exposed-headers =				#包含在响应中的逗号分隔的标题列表。  
endpoints.cors.max-age = 1800					#以秒为单位,客户端可以缓存飞行前请求的响应。  
  
#JMX ENDPOINT(EndpointMBeanExportProperties)  
endpoints.jmx.domain =							#JMX域名。如果设置,则用“spring.jmx.default-domain”的值初始化。  
endpoints.jmx.enabled = true					#启用所有端点的JMX导出。  
endpoints.jmx.static-names =					#附加到所有表示端点的MBean的ObjectName的静态属性。  
endpoints.jmx.unique-names = false				#确保ObjectNames在发生冲突时被修改。  
 
 
#flyway
flyway.baseline-description 					#对执行迁移时基准版本的描述.
flyway.baseline-on-migrate						#当迁移时发现目标schema非空,而且带有没有元数据的表时,是否自动执行基准迁移,默认false.
flyway.baseline-version							#开始执行基准迁移时对现有的schema的版本打标签,默认值为1.
flyway.check-location							#检查迁移脚本的位置是否存在,默认false.
flyway.clean-on-validation-error				#当发现校验错误时是否自动调用clean,默认false.
flyway.enabled									#是否开启flywary,默认true.
flyway.encoding									#设置迁移时的编码,默认UTF-8.
flyway.ignore-failed-future-migration			#当读取元数据表时是否忽略错误的迁移,默认false.
flyway.init-sqls								#当初始化好连接时要执行的SQL.
flyway.locations								#迁移脚本的位置,默认db/migration.
flyway.out-of-order								#是否允许无序的迁移,默认false.
flyway.password									#目标数据库的密码.
flyway.placeholder-prefix						#设置每个placeholder的前缀,默认${.
flyway.placeholder-replacement					#placeholders是否要被替换,默认true.
flyway.placeholder-suffix						#设置每个placeholder的后缀,默认}.
flyway.placeholders.[placeholder name]			#设置placeholder的value
flyway.schemas									#设定需要flywary迁移的schema,大小写敏感,默认为连接默认的schema.
flyway.sql-migration-prefix						#迁移文件的前缀,默认为V.
flyway.sql-migration-separator					#迁移脚本的文件名分隔符,默认__
flyway.sql-migration-suffix						#迁移脚本的后缀,默认为.sql
flyway.table									#flyway使用的元数据表名,默认为schema_version
flyway.target									#迁移时使用的目标版本,默认为latest version
flyway.url										#迁移时使用的JDBC URL,如果没有指定的话,将使用配置的主数据源
flyway.user										#迁移数据库的用户名
flyway.validate-on-migrate						#迁移时是否校验,默认为true.
 
#FREEMARKER(FreeMarkerAutoConfiguration)  
spring.freemarker.allowRequestOverride = false   			#设置HttpServletRequest属性是否允许覆盖(隐藏)控制器生成的相同名称的模型属性。
spring.freemarker.allowSessionOverride = false   			#设置HttpSession属性是否允许覆盖(隐藏)控制器生成的相同名称的模型属性。	
spring.freemarker.cache = true  				 			#使用模板缓存。
spring.freemarker.charset=UTF-8 				 			# Template encoding.
spring.freemarker.checkTemplateLocation = true   			#检查模板位置是否存在spring.freemarker.check-template-location=true 
spring.freemarker.contentType = text / html  	 			#Content-Type  
spring.freemarker.exposeRequestAttributes = false  			#在与模板合并之前,设置是否应该将所有请求属性添加到模型中。spring.freemarker.expose-request-attributes=false
spring.freemarker.exposeSessionAttributes = false  			#在与模板合并之前,设置是否应该将所有HttpSession属性添加到模型中。spring.freemarker.expose-session-attributes=false
spring.freemarker.exposeSpringMacroHelpers = false  		#设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用      spring.freemarker.expose-spring-macro-helpers=true
spring.freemarker.prefer-file-system-access=true 			#是否优先从文件系统加载template,以支持热加载,默认为true
spring.freemarker.prefix =  								#在构建URL时,前缀被预先指定以查看名称。
spring.freemarker.requestContextAttribute =  				#所有视图的RequestContext属性的名称.   freemarker.request-context-attribute= 
spring.freemarker.settings.* =  							#Well-known FreeMarker keys which will be passed to FreeMarker's Configuration
spring.freemarker.suffix = .ftl  							#在构建URL时附加到视图名称后面的后缀		
spring.freemarker.templateEncoding = UTF- 8  
spring.freemarker.templateLoaderPath =classpath:/templates  #设定ftl文件路径 类路径:/模板/  
spring.freemarker.viewNames =								#可以解析的视图名称的白名单  
spring.mvc.static-path-pattern=/static/**  					#设定静态文件路径,js,css等
#GIT信息  
spring.git.properties =							#生成的git信息属性文件的资源引用。  
#GROOVY模板(GroovyTemplateAutoConfiguration)  
spring.groovy.template.allow-request-override 				#指定HttpServletRequest的属性是否可以覆盖controller的model的同名项
spring.groovy.template.allow-session-override 				#指定HttpSession的属性是否可以覆盖controller的model的同名项
spring.groovy.template.cache  								#是否开启模板缓存
.spring.groovy.template.charset 							#指定Template编码
.spring.groovy.template.check-template-location 			#是否检查模板的路径是否存在.
spring.groovy.template.configuration.auto-escape 			#是否在渲染模板时自动排查model的变量,默认为: false
spring.groovy.template.configuration.auto-indent 			#是否在渲染模板时自动缩进,默认为false
spring.groovy.template.configuration.auto-indent-string 	#如果自动缩进启用的话,是使用SPACES还是TAB,默认为: SPACES
spring.groovy.template.configuration.auto-new-line 			#渲染模板时是否要输出换行,默认为false
spring.groovy.template.configuration.base-template-class 	#指定template base class.
spring.groovy.template.configuration.cache-templates 		#是否要缓存模板,默认为true
spring.groovy.template.configuration.declaration-encoding 	#在写入declaration header时使用的编码
spring.groovy.template.configuration.expand-empty-elements 	#是使用<br/>这种形式,还是<br></br>这种展开模式,默认为: false)
spring.groovy.template.configuration.locale 				#指定template locale.
spring.groovy.template.configuration.new-line-string 		#当启用自动换行时,换行的输出,默认为系统的line.separator属性的值
spring.groovy.template.configuration.resource-loader-path 	#指定groovy的模板路径,默认为classpath:/templates/
spring.groovy.template.configuration.use-double-quotes 		#指定属性要使用双引号还是单引号,默认为false
spring.groovy.template.content-type 						#指定Content-Type.
spring.groovy.template.enabled 								#是否开启groovy模板的支持.
spring.groovy.template.expose-request-attributes 			#设定所有request的属性在merge到模板的时候,是否要都添加到model中.
spring.groovy.template.expose-session-attributes 			#设定所有request的属性在merge到模板的时候,是否要都添加到model中.
spring.groovy.template.expose-spring-macro-helpers 			#设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用
spring.groovy.template.prefix 								#指定模板的前缀.
spring.groovy.template.request-context-attribute 			#指定RequestContext属性的名.
spring.groovy.template.resource-loader-path				 	#指定模板的路径,默认为: classpath:/templates/
spring.groovy.template.suffix								#指定模板的后缀
spring.groovy.template.view-names 							#指定要使用模板的视图名称.
#h2
spring.h2.console.enabled						#是否开启控制台,默认为false
spring.h2.console.path							#指定控制台路径,默认为: /h2-console
#hornetq	(HornetQProperties)  
spring.hornetq.embedded.cluster-password		#指定集群的密码,默认启动时随机生成.
spring.hornetq.embedded.data-directory			#指定Journal file 的目录. 如果不开启持久化则不必指定.
spring.hornetq.embedded.enabled					#是否开启内嵌模式,默认:true
spring.hornetq.embedded.persistent				#是否开启persistent store,默认: false
spring.hornetq.embedded.queues					#指定启动是创建的queue,多个以逗号分隔,默认: []
spring.hornetq.embedded.server-id				#指定Server ID. 默认使用自增数字,从0开始.
spring.hornetq.embedded.topics					#指定启动时创建的topic,多个以逗号分隔,默认: []
spring.hornetq.host								#指定HornetQ broker 的host,默认: localhost
spring.hornetq.mode								#指定HornetQ 的部署模式,默认是auto-detected,也可以指定native 或者 embedded.
spring.hornetq.port								#指定HornetQ broker 端口,默认: 5445
#http
spring.hateoas.apply-to-primary-object-mapper   #设定是否对object mapper也支持HATEOAS,默认为: true
spring.http.converters.preferred-json-mapper   	#是否优先使用JSON mapper来转换.
spring.http.encoding.charset 					#指定http请求和相应的Charset,默认: UTF-8
spring.http.encoding.enabled					#是否开启http的编码支持,默认为true
spring.http.encoding.force						#是否强制对http请求和响应进行编码,默认为true
#jersey
spring.jersey.filter.order 						#指定Jersey filter的order,默认为: 0
spring.jersey.init								#指定传递给Jersey的初始化参数.
spring.jersey.type								#指定Jersey的集成类型,可以是servlet或者filter.
#jms
spring.jms.jndi-name							#指定Connection factory JNDI 名称.
spring.jms.listener.acknowledge-mode			#指定ack模式,默认自动ack.
spring.jms.listener.auto-startup				#是否启动时自动启动jms,默认为: true
spring.jms.listener.concurrency					#指定最小的并发消费者数量.
spring.jms.listener.max-concurrency				#指定最大的并发消费者数量.
spring.jms.pub-sub-domain						#是否使用默认的destination type来支持 publish/subscribe,默认: false
jmx
spring.jmx.default-domain						#指定JMX domain name.
spring.jmx.enabled								#是否暴露jmx,默认为true
spring.jmx.server								#指定MBeanServer bean name. 默认为: mbeanServer)
#jooq
spring.jooq.sql-dialect							#指定JOOQ使用的SQLDialect,比如POSTGRES.
#Messages
spring.messages.basename		 							#指定message的basename,多个以逗号分隔,如果不加包名的话,默认从classpath路径开始,默认: messages
spring.messages.cache-seconds	 							#设定加载的资源文件缓存失效时间,-1的话为永不过期,默认为-1
spring.messages.encoding    			 					#设定Message bundles的编码,默认: UTF-8
#JPA
spring.jpa.database								#指定目标数据库.
spring.jpa.database-platform					#指定目标数据库的类型.
spring.jpa.generate-ddl							#是否在启动时初始化schema,默认为false
spring.jpa.hibernate.ddl-auto					#指定DDL mode (none, validate, update, create, create-drop). 当使用内嵌数据库时,默认是create-drop,否则为none.
spring.jpa.hibernate.naming-strategy			#指定命名策略.
spring.jpa.open-in-view							#是否注册OpenEntityManagerInViewInterceptor,绑定JPA EntityManager到请求线程中,默认为: true
spring.jpa.properties							#添加额外的属性到JPA provider.
spring.jpa.show-sql								#是否开启sql的log,默认为: false
#json
spring.jackson.date-format						#指定日期格式,比如yyyy-MM-dd HH:mm:ss,或者具体的格式化类的全限定名
spring.jackson.deserialization					#是否开启Jackson的反序列化
spring.jackson.generator						#是否开启json的generators.
spring.jackson.joda-date-time-format			#指定Joda date/time的格式,比如yyyy-MM-dd HH:mm:ss). 如果没有配置的话,dateformat会作为backup
spring.jackson.locale							#指定json使用的Locale.
spring.jackson.mapper							#是否开启Jackson通用的特性.
spring.jackson.parser							#是否开启jackson的parser特性.
spring.jackson.property-naming-strategy			#指定PropertyNamingStrategy (CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)或者指定PropertyNamingStrategy子类的全限定类名.
spring.jackson.serialization					#是否开启jackson的序列化.
spring.jackson.serialization-inclusion			#指定序列化时属性的inclusion方式,具体查看JsonInclude.Include枚举.
spring.jackson.time-zone						#指定日期格式化时区,比如America/Los_Angeles或者GMT+10.
#JTA
spring.jta.allow-multiple-lrc					#是否允许 multiple LRC,默认为: false
spring.jta.asynchronous2-pc						#指定两阶段提交是否可以异步,默认为: false
spring.jta.background-recovery-interval			#指定多少分钟跑一次recovery process,默认为: 1
spring.jta.background-recovery-interval-seconds	#指定多久跑一次recovery process,默认: 60
spring.jta.current-node-only-recovery			#是否过滤掉其他非本JVM的recovery,默认为: true
spring.jta.debug-zero-resource-transaction		#是否追踪没有使用指定资源的事务,默认为: false
spring.jta.default-transaction-timeout			#设定默认的事务超时时间,默认为60
spring.jta.disable-jmx							#是否禁用jmx,默认为false
spring.jta.enabled								#是否开启JTA support,默认为: true
spring.jta.exception-analyzer					#设置指定的异常分析类
spring.jta.filter-log-status					#使用Bitronix Transaction Manager时,是否写mandatory logs,开启的话,可以节省磁盘空间,但是调试会复杂写,默认为false
spring.jta.force-batching-enabled				#使用Bitronix Transaction Manager时,是否批量写磁盘,默认为true.
spring.jta.forced-write-enabled					#使用Bitronix Transaction Manager时,是否强制写日志到磁盘,默认为true
spring.jta.graceful-shutdown-interval			#当使用Bitronix Transaction Manager,指定shutdown时等待事务结束的时间,超过则中断,默认为60
spring.jta.jndi-transaction-synchronization-registry-name		#当使用Bitronix Transaction Manager时,在JNDI下得事务同步registry,默认为: java:comp/TransactionSynchronizationRegistry
spring.jta.jndi-user-transaction-name			#指定在JNDI使用Bitronix Transaction Manager的名称,默认:java:comp/UserTransaction
spring.jta.journal								#当使用Bitronix Transaction Manager,指定The journal是否disk还是null还是一个类的全限定名,默认disk
spring.jta.log-dir								#Transaction logs directory.
spring.jta.log-part1-filename					#指定The journal fragment文件1的名字,默认: btm1.tlog
spring.jta.log-part2-filename					#指定The journal fragment文件2的名字,默认: btm2.tlog
spring.jta.max-log-size-in-mb					#指定journal fragments大小的最大值. 默认: 2M
spring.jta.resource-configuration-filename		#指定Bitronix Transaction Manager配置文件名.
spring.jta.server-id							#指定Bitronix Transaction Manager实例的id.
spring.jta.skip-corrupted-logs					#是否忽略corrupted log files文件,默认为false.
spring.jta.transaction-manager-id				#指定Transaction manager的唯一标识.
spring.jta.warn-about-zero-resource-transaction	#当使用Bitronix Transaction Manager时,是否对没有使用指定资源的事务进行警告,默认为: true
#mail
spring.mail.default-encoding					#指定默认MimeMessage的编码,默认为: UTF-8
spring.mail.host								#指定SMTP server host.
spring.mail.jndi-name							#指定mail的jndi名称
spring.mail.password							#指定SMTP server登陆密码.
spring.mail.port								#指定SMTP server port.
spring.mail.properties							#指定JavaMail session属性.
spring.mail.protocol							#指定SMTP server使用的协议,默认为: smtp
spring.mail.test-connection						#指定是否在启动时测试邮件服务器连接,默认为false
spring.mail.username							#指定SMTP server的用户名.
#mobile
spring.mobile.devicedelegatingviewresolver.enable-fallback	#是否支持fallback的解决方案,默认false
spring.mobile.devicedelegatingviewresolver.enabled			#是否开始device view resolver,默认为: false
spring.mobile.devicedelegatingviewresolver.mobile-prefix	#设定mobile端视图的前缀,默认为:mobile/
spring.mobile.devicedelegatingviewresolver.mobile-suffix	#设定mobile视图的后缀
spring.mobile.devicedelegatingviewresolver.normal-prefix	#设定普通设备的视图前缀
spring.mobile.devicedelegatingviewresolver.normal-suffix	#设定普通设备视图的后缀
spring.mobile.devicedelegatingviewresolver.tablet-prefix	#设定平板设备视图前缀,默认:tablet/
spring.mobile.devicedelegatingviewresolver.tablet-suffix	#设定平板设备视图后缀.
spring.mobile.sitepreference.enabled						#是否启用SitePreferenceHandler,默认为: true
#MONGODB(Mongo性能)  
spring.data.mongodb.host =						#分贝主机  
spring.data.mongodb.port = 27017  				#连接端口(默认为  27107 )  
spring.data.mongodb.uri = 						#连接URL  
spring.mongodb.embedded.features				#指定要开启的特性,逗号分隔.
spring.mongodb.embedded.version					#指定要使用的版本,默认: 2.6.10
#MANAGEMENT HTTP SERVER(ManagementServerProperties)  
management.add-application-context-header = true#在每个响应中添加“X-Application-Context”HTTP标头。  
management.address =							#管理端点应该绑定的网络地址。  
management.context-path =						#管理端点上下文路径。例如`/执行器`  
management.port =								#管理端点HTTP端口。默认使用与应用程序相同的端口。  
management.security.enabled = true				#启用
management.security.role = ADMIN				#访问管理端点所需的角色。  
management.security.sessions 					#会话创建策略使用(always, never, if_required, stateless)。  
  
#HEALTH INDICATORS健康指标(以前的健康状况*)  
management.health.db.enabled = true				#启用数据库运行状况检查。  
management.health.defaults.enabled = true		#启用默认健康指标。  
management.health.diskspace.enabled = true		#启用磁盘空间运行状况检查。  
management.health.diskspace.path =				#用于计算可用磁盘空间的路径。  
management.health.diskspace.threshold = 0		#应该可用的最小磁盘空间(以字节为单位)。  
management.health.elasticsearch.enabled = true	#启用elasticsearch运行状况检查。  
management.health.elasticsearch.indices =		#逗号分隔的索引名称。  
management.health.elasticsearch.response-timeout = 100		#等待群集响应的时间(以毫秒为单位)。  
management.health.jms.enabled = true			#启用JMS运行状况检查。  
management.health.mail.enabled = true			#启用邮件运行状况检查。  
management.health.mongo.enabled = true			#启用MongoDB运行状况检查。  
management.health.rabbit.enabled = true			#启用RabbitMQ健康检查。  
management.health.redis.enabled = true			#启用Redis运行状况检查。  
management.health.solr.enabled = true			#启用Solr运行状况检查。  
management.health.status.order 					#以逗号分隔的健康状态列表。  
management.trace.include 						#要包含在跟踪中的项目。  
#METRICS EXPORT(MetricExportProperties)  
spring.metrics.export.aggregate.key-pattern =	#告诉聚合器如何处理源存储库中的密钥的模式。  
spring.metrics.export.aggregate.prefix =		#全局存储库的前缀(如果处于活动状态)。  
spring.metrics.export.delay-millis = 5000		#输出滴答之间的延迟(以毫秒为单位)。度量标准按照计划导出到外部源。  
spring.metrics.export.enabled = true			#启用metric 标准导出的标志(假设MetricWriter可用)。  
spring.metrics.export.excludes =				#要排除的metric 标准名称的模式列表。包括后应用。  
spring.metrics.export.includes =				#要包含的metric 标准名称的模式列表。  
spring.metrics.export.redis.key 				#Redis存储库导出密钥(如果有效)。  
spring.metrics.export.redis.prefix				#如果处于活动状态,redis存储库的前缀。  
spring.metrics.export.send-latest 				#根据不导出不变的metric 值的标志关闭所有可用的优化。  
spring.metrics.export.statsd.host =				#接收导出metric 的statsd server的主机。  
spring.metrics.export.statsd.port = 8125		#接收导出metric的statsd server的端口。  
spring.metrics.export.statsd.prefix =			#统计导出metric的前缀。  
spring.metrics.export.triggers。* =				#每个MetricWriter bean名称的特定触发器属性。  
#multipart
multipart.enabled								#是否开启文件上传支持,默认为true
multipart.file-size-threshold					#设定文件写入磁盘的阈值,单位为MB或KB,默认为0
multipart.location								#指定文件上传路径.
multipart.max-file-size							#指定文件大小最大值,默认1MB
multipart.max-request-size						#指定每次请求的最大值,默认为10MB
#mustcache
spring.mustache.cache							#是否Enable template caching.
spring.mustache.charset							#指定Template的编码.
spring.mustache.check-template-location			#是否检查默认的路径是否存在.
spring.mustache.content-type					#指定Content-Type.
spring.mustache.enabled							#是否开启mustcache的模板支持.
spring.mustache.prefix							#指定模板的前缀,默认: classpath:/templates/
spring.mustache.suffix							#指定模板的后缀,默认: .html
spring.mustache.view-names						#指定要使用模板的视图名.
#MVC(SPRING MVC相关的一些配置)  
http.mappers.json-pretty-print = false  					#打印JSON  
http.mappers.json-sort-keys = false  						#排序键  
spring.mvc.locale =											#设置固定语言环境,例如en_UK  
spring.mvc.date-format =									#设置固定的日期格式,例如dd / MM / yyyy  
spring.mvc.async.request-timeout	 						#设定async请求的超时时间,以毫秒为单位,如果没有设置的话,以具体实现的超时时间为准,比如tomcat的servlet3的话是10秒.
spring.mvc.favicon.enabled 									#是否支持favicon.ico,默认为: true
spring.mvc.ignore-default-model-on-redirect  				#在重定向时是否忽略默认model的内容,默认为true
spring.mvc.locale#指定使用的Locale.
spring.mvc.message-codes-resolver-format 					#指定message codes的格式化策略(PREFIX_ERROR_CODE,POSTFIX_ERROR_CODE).
spring.view.prefix =   										#MVC视图前缀  
spring.view.suffix =   										#...和后缀  	
spring.resources.cache-period =             				#发送到浏览器的标题缓存超时  
spring.resources.add-mappings = true         				#如果 应该添加默认映射   
#liquibase
liquibase.change-log							#Change log 配置文件的路径,默认值为classpath:/db/changelog/db.changelog-master.yaml
liquibase.check-change-log-location				#是否坚持change log的位置是否存在,默认为true.
liquibase.contexts								#逗号分隔的运行时context列表.
liquibase.default-schema						#默认的schema.
liquibase.drop-first							#是否首先drop schema,默认为false
liquibase.enabled								#是否开启liquibase,默认为true.
liquibase.password								#目标数据库密码
liquibase.url									#要迁移的JDBC URL,如果没有指定的话,将使用配置的主数据源.
liquibase.user									#目标数据用户名
#logging日志
logging.path =  							#文件路径
logging.file = myapp.log   					#文件名称
logging.config =							#如果你即想完全掌控日志配置,但又不想用logback.xml作为Logback配置的名字,可以通过logging.config属性指定自定义的名字
logging.level.root=INFO  					#日志级别  从控制台打印出来的日志级别只有ERROR, WARN 还有INFO,如果你想要打印debug级别的日志,可以配置debug=true
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR									
#rabbitmq
spring.rabbitmq.addresses						#指定client连接到的server的地址,多个以逗号分隔.
spring.rabbitmq.dynamic							#是否创建AmqpAdmin bean. 默认为: true)
spring.rabbitmq.host							#指定RabbitMQ host.默认为: localhost)
spring.rabbitmq.listener.acknowledge-mode		#指定Acknowledge的模式.
spring.rabbitmq.listener.auto-startup			#是否在启动时就启动mq,默认: true)
spring.rabbitmq.listener.concurrency			#指定最小的消费者数量.
spring.rabbitmq.listener.max-concurrency		#指定最大的消费者数量.
spring.rabbitmq.listener.prefetch				#指定一个请求能处理多少个消息,如果有事务的话,必须大于等于transaction数量.
spring.rabbitmq.listener.transaction-size		#指定一个事务处理的消息数量,最好是小于等于prefetch的数量.
spring.rabbitmq.password						#指定broker的密码.
spring.rabbitmq.port							#指定RabbitMQ 的端口,默认: 5672)
spring.rabbitmq.requested-heartbeat				#指定心跳超时,0为不指定.
spring.rabbitmq.ssl.enabled						#是否开始SSL,默认: false)
spring.rabbitmq.ssl.key-store					#指定持有SSL certificate的key store的路径
spring.rabbitmq.ssl.key-store-password			#指定访问key store的密码.
spring.rabbitmq.ssl.trust-store					#指定持有SSL certificates的Trust store.
spring.rabbitmq.ssl.trust-store-password		#指定访问trust store的密码.
spring.rabbitmq.username						#指定登陆broker的用户名.
spring.rabbitmq.virtual-host					#指定连接到broker的Virtual host.
#redis
spring.redis.database							#指定连接工厂使用的Database index,默认为: 0
spring.redis.host								#指定Redis server host,默认为: localhost
spring.redis.password							#指定Redis server的密码
spring.redis.pool.max-active					#指定连接池最大的活跃连接数,-1表示无限,默认为8
spring.redis.pool.max-idle						#指定连接池最大的空闲连接数,-1表示无限,默认为8
spring.redis.pool.max-wait						#指定当连接池耗尽时,新获取连接需要等待的最大时间,以毫秒单位,-1表示无限等待
spring.redis.pool.min-idle						#指定连接池中空闲连接的最小数量,默认为0
spring.redis.port								#指定redis服务端端口,默认: 6379
spring.redis.sentinel.master					#指定redis server的名称
spring.redis.sentinel.nodes						#指定sentinel节点,逗号分隔,格式为host:port.
spring.redis.timeout							#指定连接超时时间,毫秒单位,默认为0
#resource
spring.resources.add-mappings					#是否开启默认的资源处理,默认为true
spring.resources.cache-period					#设定资源的缓存时效,以秒为单位.
spring.resources.chain.cache					#是否开启缓存,默认为: true
spring.resources.chain.enabled					#是否开启资源 handling chain,默认为false
spring.resources.chain.html-application-cache	#是否开启h5应用的cache manifest重写,默认为: false
spring.resources.chain.strategy.content.enabled	#是否开启内容版本策略,默认为false
spring.resources.chain.strategy.content.paths	#指定要应用的版本的路径,多个以逗号分隔,默认为:[/**]
spring.resources.chain.strategy.fixed.enabled	#是否开启固定的版本策略,默认为false
spring.resources.chain.strategy.fixed.paths		#指定要应用版本策略的路径,多个以逗号分隔
spring.resources.chain.strategy.fixed.version	#指定版本策略使用的版本号
spring.resources.static-locations				#指定静态资源路径,默认为classpath:[/META-INF/resources/,/resources/, /static/, /public/]以及context:/
#security     spring security是springboot支持的权限控制系统。
security.basic.authorize-mode					#要使用权限控制模式.
security.basic.enabled							#是否开启基本的鉴权,默认为true
security.basic.path								#需要鉴权的path,多个的话以逗号分隔,默认为[/**]
security.basic.realm							#HTTP basic realm 的名字,默认为Spring
security.enable-csrf							#是否开启cross-site request forgery校验,默认为false.
security.filter-order							#Security filter chain的order,默认为0
security.headers.cache							#是否开启http头部的cache控制,默认为false.
security.headers.content-type					#是否开启X-Content-Type-Options头部,默认为false.
security.headers.frame							#是否开启X-Frame-Options头部,默认为false.
security.headers.hsts							#指定HTTP Strict Transport Security (HSTS)模式(none, domain, all).
security.headers.xss							#是否开启cross-site scripting (XSS) 保护,默认为false.
security.ignored								#指定不鉴权的路径,多个的话以逗号分隔.
security.oauth2.client.access-token-uri			#指定获取access token的URI.
security.oauth2.client.access-token-validity-seconds		#指定access token失效时长.
security.oauth2.client.additional-information.[key]			#设定要添加的额外信息.
security.oauth2.client.authentication-scheme				#指定传输不记名令牌(bearer token)的方式(form, header, none,query),默认为header
security.oauth2.client.authorities				#指定授予客户端的权限.
security.oauth2.client.authorized-grant-types	#指定客户端允许的grant types.
security.oauth2.client.auto-approve-scopes		#对客户端自动授权的scope.
security.oauth2.client.client-authentication-scheme			#传输authentication credentials的方式(form, header, none, query),默认为header方式
security.oauth2.client.client-id				#指定OAuth2 client ID.
security.oauth2.client.client-secret			#指定OAuth2 client secret. 默认是一个随机的secret.
security.oauth2.client.grant-type				#指定获取资源的access token的授权类型.
security.oauth2.client.id						#指定应用的client ID.
security.oauth2.client.pre-established-redirect-uri			#服务端pre-established的跳转URI.
security.oauth2.client.refresh-token-validity-seconds		#指定refresh token的有效期.
security.oauth2.client.registered-redirect-uri				#指定客户端跳转URI,多个以逗号分隔.
security.oauth2.client.resource-ids				#指定客户端相关的资源id,多个以逗号分隔.
security.oauth2.client.scope					#client的scope
security.oauth2.client.token-name				#指定token的名称
security.oauth2.client.use-current-uri			#是否优先使用请求中URI,再使用pre-established的跳转URI. 默认为true
security.oauth2.client.user-authorization-uri	#用户跳转去获取access token的URI.
security.oauth2.resource.id						#指定resource的唯一标识.
security.oauth2.resource.jwt.key-uri			#JWT token的URI. 当key为公钥时,或者value不指定时指定.
security.oauth2.resource.jwt.key-value			#JWT token验证的value. 可以是对称加密或者PEMencoded RSA公钥. 可以使用URI作为value.
security.oauth2.resource.prefer-token-info		#是否使用token info,默认为true
security.oauth2.resource.service-id				#指定service ID,默认为resource.
security.oauth2.resource.token-info-uri			#token解码的URI.
security.oauth2.resource.token-type				#指定当使用userInfoUri时,发送的token类型.
security.oauth2.resource.user-info-uri			#指定user info的URI
security.oauth2.sso.filter-order				#如果没有显示提供WebSecurityConfigurerAdapter时指定的Filter order.
security.oauth2.sso.login-path					#跳转到SSO的登录路径默认为/login.
security.require-ssl							#是否对所有请求开启SSL,默认为false.
security.sessions								#指定Session的创建策略(always, never, if_required, stateless).
security.user.name								#指定默认的用户名,默认为user.
security.user.password							#默认的用户密码.
security.user.role								#默认用户的授权角色.
#sendgrid
spring.sendgrid.password						#指定SendGrid password.
spring.sendgrid.proxy.host						#指定SendGrid proxy host.
spring.sendgrid.proxy.port						#指定SendGrid proxy port.
spring.sendgrid.username						#指定SendGrid username.
#server配置
server.address								#指定server绑定的地址
server.compression.enabled					#是否开启压缩,默认为false.
server.compression.excluded-user-agents		#指定不压缩的user-agent,多个以逗号分隔,默认值为:text/html,text/xml,text/plain,text/css
server.compression.mime-types				#指定要压缩的MIME type,多个以逗号分隔.
server.compression.min-response-size		#执行压缩的阈值,默认为2048
server.context-parameters.[param name]		#设置servlet context 参数
server.context-path							#设定应用的context-path.
server.display-name							#设定应用的展示名称,默认: application
server.jsp-servlet.class-name				#设定编译JSP用的servlet,默认: org.apache.jasper.servlet.JspServlet)
server.jsp-servlet.init-parameters.[param name]				#设置JSP servlet 初始化参数.
server.jsp-servlet.registered				#设定JSP servlet是否注册到内嵌的servlet容器,默认true
server.port									#设定http监听端口
server.context-path							#设定dispatcher servlet的监听路径,默认为: /
#SHELL      REMOTE SHELL  
shell.auth = simple								#认证类型。根据环境自动检测。  
shell.auth.jaas.domain =my-domain				#JAAS域。  
shell.auth.key.path =							#认证密钥的路径。这应该指向一个有效的“.pem”文件。  
shell.auth.simple.user.name = user				#登录用户。  
shell.auth.simple.user.password =				#登录密码。  
shell.auth.spring.roles = ADMIN					#用于登录到CRaSH控制台的所需角色的逗号分隔列表。  
shell.command-path-patterns = classpath *:/ commands / **,classpath *:/ crash / commands / **#用于查找命令的模式。  
shell.command-refresh-interval = -1				#扫描更改并在必要时更新命令(以秒为单位)。  
shell.config-path-patterns = 					#用于查找配置的模式。  
shell.disabled-commands 						#禁用命令的逗号分隔列表。  
shell.disabled-plugins =						#禁用逗号分隔的插件列表。根据环境,某些插件默认是禁用的。  
shell.ssh.auth-timeout =						#用户提示重新登录后的毫秒数。  
shell.ssh.enabled = true						#启用CRaSH SSH支持。  
shell.ssh.idle-timeout =						#关闭未使用的连接之后的毫秒数。  
shell.ssh.key-path =							#SSH服务器密钥的路径。  
shell.ssh.port = 2000							#SSH端口。  
shell.telnet.enabled = false					#启用CRaSH telnet支持。如果TelnetPlugin可用,则默认启用。  
shell.telnet.port = 5000						#Telnet端口。  
#social
spring.social.auto-connection-views				#是否开启连接状态的视图,默认为false
spring.social.facebook.app-id					#指定应用id
spring.social.facebook.app-secret				#指定应用密码
spring.social.linkedin.app-id					#指定应用id
spring.social.linkedin.app-secret				#指定应用密码
spring.social.twitter.app-id					#指定应用ID.
spring.social.twitter.app-secret				#指定应用密码
#ssl配置
server.ssl.ciphers								#是否支持SSL ciphers.
server.ssl.client-auth							#设定client authentication是wanted 还是 needed.
server.ssl.enabled								#是否开启ssl,默认: true
server.ssl.key-alias							#设定key store中key的别名.
server.ssl.key-password							#访问key store中key的密码.
server.ssl.key-store							#设定持有SSL certificate的key store的路径,通常是一个.jks文件.
server.ssl.key-store-password					#设定访问key store的密码.
server.ssl.key-store-provider					#设定key store的提供者.
server.ssl.key-store-type						#设定key store的类型.
server.ssl.protocol								#使用的SSL协议,默认: TLS
server.ssl.trust-store							#持有SSL certificates的Trust store.
server.ssl.trust-store-password					#访问trust store的密码.
server.ssl.trust-store-provider					#设定trust store的提供者.
server.ssl.trust-store-type						#指定trust store的类型.
#tomcat服务器配置(ServerProperties)  
server.port = 8080   										#端口
server.address =  											#该服务绑定IP地址,启动服务器时如本机不是该IP地址则抛出异常启动失败,只有特殊需求的情况下才配置
server.session-timeout =									#会话超时秒数  默认30
server.servlet.context-path =   							#上下文路径,默认为  '/'  
server.servlet-path =										#servlet路径,默认为  '/'  
server.tomcat.access-log-pattern =							#访问日志的日志模式  
server.tomcat.access-log-enabled = false  					#启用访问日志记录  
server.tomcat.protocol-header = x -forwarded-proto 			#ssl转发标头  
server.tomcat.accesslog.pattern								#设定access logs的格式,默认: common
server.tomcat.accesslog.prefix								#设定Log 文件的前缀,默认: access_log
server.tomcat.accesslog.suffix								#设定Log 文件的后缀,默认: .log
server.tomcat.background-processor-delay = 30 ; 			# 后台线程方法的Delay大小: 30
server.tomcat.basedir										#设定Tomcat的base 目录,如果没有指定则使用临时目录.
server.tomcat.internal-proxies								#设定信任的正则表达式,默认:“10.d{1,3}.d{1,3}.d{1,3}| 192.168.d{1,3}.d{1,3}|
															#169.254.d{1,3}.d{1,3}| 127.d{1,3}.d{1,3}.d{1,3}| 172.1[6-9]{1}.d{1,3}
															#.d{1,3}| 172.2[0-9]{1}.d{1,3}.d{1,3}|172.3[0-1]{1}.d{1,3}.d{1,3}”
server.tomcat.max-http-header-size							#设定http header的最小值,默认: 0
server.tomcat.max-threads									#设定tomcat的最大工作线程数,默认为: 0
server.tomcat.port-header									#设定http header使用的,用来覆盖原来port的value.
server.tomcat.protocol-header								#设定Header包含的协议,通常是 X-Forwarded-Proto,如果remoteIpHeader有值,则将设置为RemoteIpValve.
server.tomcat.protocol-header-https-value					#设定使用SSL的header的值,默认https.
server.tomcat.remote-ip-header								#设定remote IP的header,如果remoteIpHeader有值,则设置为RemoteIpValve
server.tomcat.uri-encoding									#设定URI的解码字符集.
#THYMELEAF(Thymeleaf 模板)  
spring.thymeleaf.prefix =    								#类路径:/模板/  检查模板位置
spring.thymeleaf.suffix =  
spring.thymeleaf.mode = HTML5  								#模板的模式
spring.thymeleaf.encoding = UTF- 8  
spring.thymeleaf.content-type = text / html#; charset = <编码>  
spring.thymeleaf.cache = true  								#这个开发配置为false,避免改了模板还要重启服务器 
#undertow
server.undertow.access-log-dir					#设定Undertow access log 的目录,默认: logs
server.undertow.access-log-enabled				#是否开启access log,默认: false
server.undertow.access-log-pattern				#设定access logs的格式,默认: common
server.undertow.accesslog.dir					#设定access log 的目录.
server.undertow.buffer-size						#设定buffer的大小.
server.undertow.buffers-per-region				#设定每个region的buffer数
server.undertow.direct-buffers					#设定堆外内存
server.undertow.io-threads						#设定I/O线程数.
server.undertow.worker-threads					#设定工作线程数
#velocity
spring.velocity.allow-request-override			#指定HttpServletRequest的属性是否可以覆盖controller的model的同名项
spring.velocity.allow-session-override			#指定HttpSession的属性是否可以覆盖controller的model的同名项
spring.velocity.cache							#是否开启模板缓存
spring.velocity.charset							#设定模板编码
spring.velocity.check-template-location			#是否检查模板路径是否存在.
spring.velocity.content-type					#设定ContentType的值
spring.velocity.date-tool-attribute				#设定暴露给velocity上下文使用的DateTool的名
spring.velocity.enabled							#设定是否允许mvc使用velocity
spring.velocity.expose-request-attributes		#是否在merge模板的时候,将request属性都添加到model中
spring.velocity.expose-session-attributes		#是否在merge模板的时候,将HttpSession属性都添加到model中
spring.velocity.expose-spring-macro-helpers		#设定是否以springMacroRequestContext的名来暴露RequestContext给Spring’s macro类库使用
spring.velocity.number-tool-attribute			#设定暴露给velocity上下文的NumberTool的名
spring.velocity.prefer-file-system-access		#是否优先从文件系统加载模板以支持热加载,默认为true
spring.velocity.prefix							#设定velocity模板的前缀.
spring.velocity.properties						#设置velocity的额外属性.
spring.velocity.request-context-attribute		#设定RequestContext attribute的名.
spring.velocity.resource-loader-path			#设定模板路径,默认为: classpath:/templates/
spring.velocity.suffix							#设定velocity模板的后缀.
spring.velocity.toolbox-config-location			#设定Velocity Toolbox配置文件的路径,比如 /WEB-INF/toolbox.xml.
spring.velocity.view-names						#设定需要解析的视图名称.

  

Springboot基础核心

1.Springboot介绍

 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。用我的话来理解,就是spring boot其实不是什么新的框架,它默认配置了很多框架的使用方式,就像maven整合了所有的jar包,spring boot整合了所有的框架

2.Springboot项目搭建

(1).通过Eclipse进行构建

(2).通过Idea进行构建

(3).通过Spring网站进行构建(推荐)

  

访问https://start.spring.io/
选择构建工具Maven Project、Spring Boot版本
点击Generate Project下载项目压缩包

 

 3.Springboot项目结构

 

src/main/java  程序开发以及主程序入口
src/main/resources 配置文件
src/test/java  测试程序

 

4.Springboot配置文件

pom.xml文件中默认有两个模块:

spring-boot-starter:核心模块,包括自动配置支持、日志和YAML;

spring-boot-starter-test:测试模块,包括JUnit、Hamcrest、Mockito。

Web模块引入  

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

 

 Springboot默认配置文件application.properties的常见配置属性

 使用spring boot可以非常方便、快速搭建项目,使我们不用关心框架之间的兼容性,适用版本等各种问题,我们想使用任何东西,仅仅添加一个配置就可以,所以使用sping boot非常适合构建微服务。

5.Springboot常用注解

  1. @SpringBootApplication 

    在系统启动类里面,都加入了此启动注解,此注解是个组合注解,包括@SpringBootConfiguration、@EnableAutoConfiguration和@ComponentScan注解。

    @SpringBootConfiguration 继承至@Configuration,对于熟悉spring的开发者而言,此标注当前类是配置类,并会将当前类内声明的一个或多个以@Bean注解标记的方法的实例纳入到srping容器中,并且实例名就是方法名。

    @EnableAutoConfiguration 这个注解就是springboot能自动进行配置的魔法所在了。主要是通过此注解,能所有符合自动配置条件的bean的定义加载到spring容器中

    @ComponentScan 这个熟悉spring的开发者也应该熟悉,会扫描当前包及其子包下被@Component,@Controller,@Service,@Repository等注解标记的类并纳入到spring容器中进行管理。

  2. @Controller 和 @RestController 

    @RestController 是Spring4之后加入的注解,原来在@Controller中返回json需要@ResponseBody来配合,如果直接用@RestController替代@Controller就不需要再配置@ResponseBody,默认返回json格式。而@Controller是用来创建处理http请求的对象,一般结合@RequestMapping使用。

  3. @RequestMapping 

    一个用来处理请求地址映射的注解,可用于类或方法上。用于类上,表示类中的所有响应请求的方法都是以该地址作为父路径。

    常用属性:value, method, consumes,produces, params,headers;
    value: 指定请求的实际地址,指定的地址可以是URI Template 模式(后面将会说明);method: 指定请求的method类型, GET、POST、PUT、DELETE等;
    consumes: 指定处理请求的提交内容类型(Content-Type),例如application/json, text/html;produces: 指定返回的内容类型,仅当request请求头中的(Accept)类型中包含该指定类型才返回;
    params: 指定request中必须包含某些参数值是,才让该方法处理。headers: 指定request中必须包含某些指定的header值,才能让该方法处理请求。

    一个用来处理请求地址映射的注解,可用于类或方法上。用于类上,表示类中的所有响应请求的方法都是以该地址作为父路径。

    @GetMapping 等同于 @RequestMapping(method = RequestMethod.GET)
    @PostMapping 等同于 @RequestMapping(method = RequestMethod.POST)
    @PutMapping 等同于 @RequestMapping(method = RequestMethod.PUT)
    @DeleteMapping 等同于 @RequestMapping(method = RequestMethod.DELETE)
    @PatchMapping 等同于 @RequestMapping(method = RequestMethod.PATCH) 

  4. @RequestBody和@ResponseBody  

    @RequestBody注解允许request的参数在reqeust体中,常常结合前端POST请求,进行前后端交互。

    @ResponseBody注解支持将的参数在reqeust体中,通常返回json格式给前端。

  5. @PathVariable、@RequestParam 

    @PathVariable 
    当使用@RequestMapping URI template 样式映射时, 即 someUrl/{paramId}, 这时的paramId可通过 @Pathvariable注解绑定它传过来的值到方法的参数上。

     

     

  6. @Component、@Service、@Repository 

    @Component 最普通的组件,可以被注入到spring容器进行管理
    @Repository 作用于持久层
    @Service 作用于业务逻辑层

Excel客户等级星级表达

用工具:REPT函数+IF函数

 

为了直观地表示一定的评级,用户经常使用“★” 的多少来迸行表述。如果现在需要对客户的级别迸行 表述,在Excel中同样可以借助“★”来表示。比如某商 城会员根据积分分为普通会员(小于57分,对应三星级 以下会员)、高级会员(积分在57~76分,对应三星级 会员)和VIP会员(积分大于76分,四星级以上会员)三 档,如果手动迸行分类填写,费时费力,借助REPT函 数和IF函数,则可以将会员级别更直观地体现出来。

=REPT("★",B2/19)

REPT 函数格式是”REPT (text, number_times)”, 其中text是指需要重复显示的文本,number_times 则表示指定文本重复次数的整数(如果number_times不是整数,则将被截尾取整)。而通过积分规则可以知道,这里每19个积分对应 一颗星,因此用户只要在=2输入公式“?REPT4 ★”, B2/19 )”,表示使用=2的数值除以19得到重复显示文 本数(文本则为“ ★ ”符号),这样将公式下拉填充后, 就可以直接看到客户的星级了 如下图

 

IF函数则可以将客户星级标注为对应的级别,定位到D2输入公式

=IF(B2<57,"普通会员",IF(B2<76, "高级会员","VIP会员"))

 这里使用嵌套 函数对B2的值进行判断,按照积分的标准显示指定的 会员名称,同上下拉公式后,就可以显示所有会员级 别名称。经过这样的设计,会员是什么星级,对应什么 级别的会员是不是一目了然了

 

常用软件分类运维或个人收藏软件必备,及文件夹打包下载

下载工具
主题壁纸
其它软件
办公软件
压缩刻录
图形图象
安全杀毒
手机数码
操作系统
教育学习
浏览器
游戏娱乐
系统工具
编程开发
网络应用
聊天工具
股票网银
视频软件
输入法
阅读翻译
音乐软件
下载工具专用下载器
下载工具通用下载器
其它软件出行查询
其它软件天文地理
其它软件日历闹钟
其它软件电子账本
办公软件PDF转换
办公软件办公常用
办公软件文档处理
办公软件记事管理
办公软件邮件
压缩刻录光盘刻录
压缩刻录压缩工具
压缩刻录虚拟光驱
图形图象CAD图形
图形图象图象处理
图形图象截图软件
图形图象看图软件
手机数码刷机工具
手机数码手机模拟器
手机数码数码转换
手机数码苹果工具
操作系统手机
操作系统电脑
操作系统手机Android
操作系统手机IOS
操作系统电脑LINUX
操作系统电脑MacOS
操作系统电脑UNIX
操作系统电脑Windows
教育学习外语工具
教育学习幼儿教育
教育学习电子书籍
教育学习考试练习
浏览器双核浏览器
浏览器游戏浏览器
浏览器高速浏览器
游戏娱乐休闲益智
游戏娱乐游戏平台
游戏娱乐游戏辅助
系统工具WIN自带工具
系统工具备份还原
系统工具桌面工具
系统工具硬件检测
系统工具系统优化
系统工具驱动工具
编程开发安卓开发
编程开发开发平台
编程开发辅助工具
编程开发运行库
网络应用上传下载
网络应用上网工具
网络应用云存储
网络应用网络加速
网络应用远程工具
聊天工具游戏语音
聊天工具社交聊天
聊天工具网络电话
聊天工具视频聊天
股票网银网银软件
股票网银股票交易
股票网银股票行情
视频软件字幕制作
视频软件本地播放
视频软件格式转换
视频软件网络视频
视频软件视频编辑
阅读翻译PDF阅读器
阅读翻译小说阅读器
阅读翻译翻译词典
音乐软件K歌软件
音乐软件在线音乐
音乐软件网络电台
音乐软件音频处理

 

链接:https://pan.baidu.com/s/1egQjVg_uCOIw28-k8H7ZeA
提取码:3ujp
复制这段内容后打开百度网盘手机App,操作更方便哦

 

Java NIO系列使用示例

  1 package com.nio.test;
  2 
  3 import java.io.IOException;
  4 import java.io.RandomAccessFile;
  5 import java.net.InetSocketAddress;
  6 import java.nio.ByteBuffer;
  7 import java.nio.CharBuffer;
  8 import java.nio.channels.DatagramChannel;
  9 import java.nio.channels.FileChannel;
 10 import java.nio.channels.Pipe;
 11 import java.nio.channels.ServerSocketChannel;
 12 import java.nio.channels.SocketChannel;
 13 import java.nio.charset.Charset;
 14 import java.nio.charset.CharsetDecoder;
 15 import java.nio.charset.CoderResult;
 16 import java.nio.file.Files;
 17 import java.nio.file.LinkOption;
 18 import java.nio.file.Path;
 19 import java.nio.file.Paths;
 20 
 21 public class ChannelTest {
 22     public static void main(String[] args) throws Exception {
 23         new ChannelTest().filewrite();
 24         new ChannelTest().byteBufferUtf8();
 25         new ChannelTest().fileread();
 26         new ChannelTest().clientsocket();
 27         new ChannelTest().serverSocket();
 28         new ChannelTest().serverDatagram();
 29         new ChannelTest().clientDatagram();
 30         new ChannelTest().pipe();
 31         new ChannelTest().NIOPath();
 32     }
 33 
 34     private void fileread() {
 35         RandomAccessFile aFile;
 36         Charset charset = Charset.forName("UTF-8");
 37         CharsetDecoder decoder = charset.newDecoder();
 38         try {
 39             // 在使用FileChannel之前,必须先打开它。但是,我们无法直接打开一个FileChannel,
 40             // 需要通过使用一个InputStream、OutputStream或RandomAccessFile来获取一个FileChannel实例
 41             aFile = new RandomAccessFile("src/com/nio/test/nio-data.txt", "rw");
 42 
 43             FileChannel inChannel = aFile.getChannel();
 44             // 首先,分配一个Buffer。从FileChannel中读取的数据将被读到Buffer中。
 45             // create buffer with capacity of 48 byte
 46             ByteBuffer byteBuffer = ByteBuffer.allocate(48);// read into buffer.
 47             CharBuffer charBuffer = CharBuffer.allocate(48);
 48 
 49             // 调用多个read()方法之一 从FileChannel中读取数据。
 50             int bytesRead = inChannel.read(byteBuffer);
 51 
 52             char[] tmp = null; // 临时存放转码后的字符
 53             byte[] remainByte = null;// 存放decode操作后未处理完的字节。decode仅仅转码尽可能多的字节,此次转码不了的字节需要缓存,下次再转
 54             int leftNum = 0; // 未转码的字节数
 55             
 56             while (bytesRead != -1) {
 57 
 58                 //System.out.println("Read " + bytesRead);
 59                 byteBuffer.flip(); // make buffer ready for read
 60                 decoder.decode(byteBuffer, charBuffer, false);
 61                 
 62                 charBuffer.flip();
 63 
 64                 remainByte = null;
 65                 leftNum = byteBuffer.limit() - byteBuffer.position();
 66                 if (leftNum > 0) { // 记录未转换完的字节
 67                     remainByte = new byte[leftNum];
 68                     byteBuffer.get(remainByte, 0, leftNum);
 69                 }
 70                 
 71                 // 输出已转换的字符
 72                 tmp = new char[charBuffer.length()];
 73                 while (charBuffer.hasRemaining()) {
 74                     charBuffer.get(tmp);
 75                     System.out.print(new String(tmp));
 76                 }
 77                 
 78                 byteBuffer.clear(); // make buffer ready for writing
 79                 charBuffer.clear();
 80 
 81                 if (remainByte != null) {
 82                     byteBuffer.put(remainByte); // 将未转换完的字节写入bBuf,与下次读取的byte一起转换
 83                 }
 84                 
 85                 bytesRead = inChannel.read(byteBuffer);
 86             }
 87             
 88             aFile.close();
 89         } catch (Exception e) {
 90             // TODO Auto-generated catch block
 91             e.printStackTrace();
 92         }
 93     }
 94 
 95     private void filewrite() throws Exception {
 96         RandomAccessFile accessFile = new RandomAccessFile("src/com/nio/test/nio-data11.txt", "rw");
 97         FileChannel fileChannel = accessFile.getChannel();
 98         String newDate = "New String to write to file" + System.currentTimeMillis();
 99         ByteBuffer buffer = ByteBuffer.allocate(48);
100         buffer.clear();
101         buffer.put(newDate.getBytes());
102         buffer.flip();
103         while (buffer.hasRemaining()) {
104             fileChannel.write(buffer);
105         }
106 
107         /**
108          * FileChannel的truncate方法
109          * 可以使用FileChannel.truncate()方法截取一个文件。截取文件时,文件将中指定长度后面的部分将被删除。如:
110          * 
111          * 1 channel.truncate(1024); 这个例子截取文件的前1024个字节。
112          */
113         //fileChannel.truncate(12);
114         /**
115          * FileChannel.force()方法将通道里尚未写入磁盘的数据制写到磁盘上。出于性能方面的考虑,操作系统会将数据缓存在内存中,
116          * 所以无法保证写入到FileChannel里的数据一定会即时写到磁盘上。要保证这一点,需要调用force()方法。
117          */
118         fileChannel.force(true);// force()方法有一个boolean类型的参数,指明是否同时将文件元数据(权限信息等)写到磁盘上。
119 
120         fileChannel.close();
121     }
122 
123     private void clientsocket() throws Exception {
124         SocketChannel socketChannel = SocketChannel.open();
125         //可以设置 SocketChannel 为非阻塞模式(non-blocking mode).设置之后,就可以在异步模式下调用connect(), read() 和write()了。
126         socketChannel.configureBlocking(false);
127         socketChannel.connect(new InetSocketAddress("127.0.0.1", 60000));
128         
129         //为非阻塞模式的判断用
130         while(!socketChannel.finishConnect()){
131             socketChannelRead(socketChannel);
132         }
133     }
134     
135     /**
136      * 
137      * ServerSocketChannel
138      * 
139      * Java NIO中的 ServerSocketChannel 是一个可以监听新进来的TCP连接的通道, 
140      * 就像标准IO中的ServerSocket一样。ServerSocketChannel类在 java.nio.channels包中。
141      * 
142      * @throws Exception 
143      * 
144      */
145     private void serverSocket() throws Exception {
146         // 通过调用 ServerSocketChannel.open() 方法来打开ServerSocketChannel.
147         ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
148         serverSocketChannel.socket().bind(new InetSocketAddress(60000));
149         // ServerSocketChannel可以设置成非阻塞模式。在非阻塞模式下,accept()
150         // 方法会立刻返回,如果还没有新进来的连接,返回的将是null。
151         // 因此,需要检查返回的SocketChannel是否是null.
152         serverSocketChannel.configureBlocking(false);
153         // 通常不会仅仅只监听一个连接,在while循环中调用 accept()方法.
154         while (true) {
155             // 监听新进来的连接
156             // 通过 ServerSocketChannel.accept() 方法监听新进来的连接。当
157             // accept()方法返回的时候,它返回一个包含新进来的连接的 SocketChannel。
158             // 因此, accept()方法会一直阻塞到有新连接到达。
159             SocketChannel socketChannel = serverSocketChannel.accept();
160 
161             // 非阻塞模式
162             if (socketChannel != null) {
163                 socketChannelRead(socketChannel);
164             }
165             //通过调用ServerSocketChannel.close() 方法来关闭ServerSocketChannel
166             // serverSocketChannel.close();
167         }
168     }
169     
170     private static StringBuilder socketChannelRead(SocketChannel socketChannel) throws Exception {
171         
172         StringBuilder sb = new StringBuilder();
173         
174         Charset charset = Charset.forName("GBK");
175         CharsetDecoder decoder = charset.newDecoder();
176 
177         ByteBuffer byteBuffer = ByteBuffer.allocate(10);
178         CharBuffer charBuffer = CharBuffer.allocate(10);
179 
180         int bytesRead = socketChannel.read(byteBuffer);
181 
182         char[] tmp = null; // 临时存放转码后的字符
183         byte[] remainByte = null;// 存放decode操作后未处理完的字节。decode仅仅转码尽可能多的字节,此次转码不了的字节需要缓存,下次再转
184         int leftNum = 0; // 未转码的字节数
185 
186         while (bytesRead != -1) {
187 
188             // System.out.println("Read " + bytesRead);
189             byteBuffer.flip(); // make buffer ready for read
190             CoderResult result = decoder.decode(byteBuffer, charBuffer, false);
191 //            System.out.println("result:"+ result);
192             charBuffer.flip();
193 
194             remainByte = null;
195             leftNum = byteBuffer.limit() - byteBuffer.position();
196             if (leftNum > 0) { // 记录未转换完的字节
197                 remainByte = new byte[leftNum];
198                 byteBuffer.get(remainByte, 0, leftNum);
199             }
200 
201             // 输出已转换的字符
202             tmp = new char[charBuffer.length()];
203             while (charBuffer.hasRemaining()) {
204                 charBuffer.get(tmp);
205                 //sb.append(tmp);
206                 System.out.print(new String(tmp));
207             }
208 
209             byteBuffer.clear(); // make buffer ready for writing
210             charBuffer.clear();
211 
212             if (remainByte != null) {
213                 byteBuffer.put(remainByte); // 将未转换完的字节写入bBuf,与下次读取的byte一起转换
214             }
215             bytesRead = socketChannel.read(byteBuffer);
216         }
217         return sb;
218     }
219     
220     /**
221      * Java NIO中的DatagramChannel是一个能收发UDP包的通道。
222      * 因为UDP是无连接的网络协议,所以不能像其它通道那样读取和写入。它发送和接收的是数据包。
223      * 
224      * @throws Exception
225      */
226     private void serverDatagram() throws Exception {
227         /**
228          * 这个例子打开的 DatagramChannel可以在UDP端口9999上接收数据包。
229          */
230         DatagramChannel channel = DatagramChannel.open();
231         channel.socket().bind(new InetSocketAddress(60000));
232         
233         Charset charset = Charset.forName("GBK");
234         CharsetDecoder decoder = charset.newDecoder();
235         
236         //通过receive()方法从DatagramChannel接收数据
237         //receive()方法会将接收到的数据包内容复制到指定的Buffer.
238         //如果Buffer容不下收到的数据,多出的数据将被丢弃。
239         ByteBuffer byteBuffer = ByteBuffer.allocate(48);
240         CharBuffer charBuffer = CharBuffer.allocate(48);
241         byteBuffer.clear();
242         channel.receive(byteBuffer);
243         
244         char[] tmp = null; // 临时存放转码后的字符
245         while(true){
246             byteBuffer.flip();
247             
248             CoderResult result = decoder.decode(byteBuffer, charBuffer, false);
249             
250             charBuffer.flip();
251             tmp = new char[charBuffer.length()];
252             while (charBuffer.hasRemaining()) {
253                 charBuffer.get(tmp);
254                 System.out.print(new String(tmp));
255             }
256             byteBuffer.clear();
257             charBuffer.clear();
258             channel.receive(byteBuffer);
259         }
260     }
261     /**
262      * 可以将DatagramChannel“连接”到网络中的特定地址的。由于UDP是无连接的,
263      * 连接到特定地址并不会像TCP通道那样创建一个真正的连接。
264      * 而是锁住DatagramChannel ,让其只能从特定地址收发数据。
265      * 当连接后,也可以使用read()和write()方法,就像在用传统的通道一样。只是在数据传送方面没有任何保证。
266      * 
267      * @throws Exception
268      */
269     private void clientDatagram() throws Exception {
270         DatagramChannel channel = DatagramChannel.open();
271         String newData = "New^啊&ng& to write to fasdfsdafsdfdsfsadf1JLKJL)(&)&*(&&ile..." + System.currentTimeMillis();
272         ByteBuffer buf = ByteBuffer.allocate(480);
273         buf.clear();
274         buf.put(newData.getBytes("GBK"));
275         buf.flip();
276         
277         //通过send()方法从DatagramChannel发送数据  即使下面的地址无法连接也是可以发送数据的。
278         int bytesSent = channel.send(buf, new InetSocketAddress("127.0.0.1", 60000));
279         //UDP在数据传送方面没有任何保证。
280     }
281     
282     /**
283      * Java NIO 管道是2个线程之间的单向数据连接。Pipe有一个source通道和一个sink通道。
284      * 数据会被写到sink通道,从source通道读取。
285      * @throws Exception 
286      */
287     private void pipe() throws Exception {
288         
289         Pipe pipe = Pipe.open();
290 
291         //构建一条线程 ,获取管道的SinkChannel,用于数据录入
292         Thread thread = new Thread(() -> {
293             // 向管道写数据
294             // 要向管道写数据,需要访问sink通道。
295             // 通过调用SinkChannel的write()方法,将数据写入SinkChannel,像这样:
296             Pipe.SinkChannel sinkChannel = pipe.sink();
297             String newData = "New String to write to file..." + System.currentTimeMillis();
298             ByteBuffer buf = ByteBuffer.allocate(48);
299             buf.clear();
300             try {
301                 buf.put(newData.getBytes("GBK"));
302 
303                 buf.flip();
304                 while (buf.hasRemaining()) {
305                     sinkChannel.write(buf);
306                 }
307             } catch (Exception e) {
308                 // TODO Auto-generated catch block
309                 e.printStackTrace();
310             }
311         });
312         
313         //构建一条线程 ,让其去获取到SinkChannel录入的数据并输出
314         Thread thread1 = new Thread(() -> {
315             // 从管道读取数据
316             // 从读取管道的数据,需要访问source通道,
317             // 调用source通道的read()方法来读取数据,
318             Pipe.SourceChannel sourceChannel = pipe.source();
319 
320             Charset charset = Charset.forName("GBK");
321             CharsetDecoder decoder = charset.newDecoder();
322 
323             ByteBuffer byteBuffer = ByteBuffer.allocate(48);
324             CharBuffer charBuffer = CharBuffer.allocate(48);
325 
326             char[] tmp = null; // 临时存放转码后的字符
327             byte[] remainByte = null;// 存放decode操作后未处理完的字节。decode仅仅转码尽可能多的字节,此次转码不了的字节需要缓存,下次再转
328             int leftNum = 0; // 未转码的字节数
329 
330             // read()方法返回的int值会告诉我们多少字节被读进了缓冲区。
331             int bytesRead;
332             try {
333                 bytesRead = sourceChannel.read(byteBuffer);
334 
335                 while (bytesRead != -1) {
336 
337                     // System.out.println("Read " + bytesRead);
338                     byteBuffer.flip(); // make buffer ready for read
339                     CoderResult result = decoder.decode(byteBuffer, charBuffer, false);
340                     // System.out.println("result:"+ result);
341                     charBuffer.flip();
342 
343                     remainByte = null;
344                     leftNum = byteBuffer.limit() - byteBuffer.position();
345                     if (leftNum > 0) { // 记录未转换完的字节
346                         remainByte = new byte[leftNum];
347                         byteBuffer.get(remainByte, 0, leftNum);
348                     }
349 
350                     // 输出已转换的字符
351                     tmp = new char[charBuffer.length()];
352                     while (charBuffer.hasRemaining()) {
353                         charBuffer.get(tmp);
354                         // sb.append(tmp);
355                         System.out.print(new String(tmp));
356                     }
357 
358                     byteBuffer.clear(); // make buffer ready for writing
359                     charBuffer.clear();
360 
361                     if (remainByte != null) {
362                         byteBuffer.put(remainByte); // 将未转换完的字节写入bBuf,与下次读取的byte一起转换
363                     }
364                     bytesRead = sourceChannel.read(byteBuffer);
365                 }
366             } catch (IOException e) {
367                 // TODO Auto-generated catch block
368                 e.printStackTrace();
369             }
370         });
371         
372         thread.run();
373         Thread.sleep(2000L);
374         thread1.run();
375         
376     }
377     
378     /**
379      * Path接口是java NIO2的一部分。首次在java 7中引入。Path接口在java.nio.file包下,
380      * 所以全称是java.nio.file.Path。 java中的Path表示文件系统的路径。可以指向文件或文件夹。
381      * 也有相对路径和绝对路径之分。绝对路径表示从文件系统的根路径到文件或是文件夹的路径。
382      * 相对路径表示从特定路径下访问指定文件或文件夹的路径。相对路径的概念可能有点迷糊,可以自己百度一下。
383      * 不要将文件系统的path和操作系统的环境变量path搞混淆。java.nio.file.Path接口和操作系统的path环境变量没有任何关系。
384      * 在很多方面,java.nio.file.Path接口和java.io.File有相似性,但也有一些细微的差别。
385      * 在很多情况下,可以用Path来代替File类。
386      */
387     private void NIOPath() {
388         //为了使用java.nio.file.Path实例,必须首先创建它。可以使用Paths 类的静态方法Paths.get()来产生一个实例。
389         //请注意例子开头的两个import语句。想要使用Paths类和Path接口,必须首先引入相应包。
390         //其次,注意Paths.get(“c:\data\myfile.txt”)的用法。
391         //其使用了Paths.get方法创建了Path的实例。它是一个工厂方法。
392         Path path = Paths.get("c:\data\myfile.txt");//绝对路径Path
393         
394         
395         //创建相对路径Path
396         //java NIO Path类也能使用相对路径。可以通过Paths.get(basePath, relativePath)创建一个相对路径Path。
397         Path projects = Paths.get("d:\data", "projects");
398         //创建了一个指向d:dataprojects文件夹的实例。
399         Path file = Paths.get("d:\data", "projects\a-project\myfile.txt");
400         //创建了一个指向 d:dataprojectsa-projectmyfile.txt 文件的实例。
401         //.表示当前路径。例如,如果以如下方式创建一个相对路径:
402         //创建的Path实例对应的路径就是运行这段代码的项目工程目录。
403         Path currentDir = Paths.get(".");
404         System.out.println(currentDir.toAbsolutePath());
405         //..表示父类目录。
406         Path parentDir = Paths.get("..");
407         String path1 = "d:\data\projects\a-project\..\another-project";
408         Path parentDir2 = Paths.get(path1);
409         //d:dataprojectsanother-project在a-project目录后面的..符号,
410         //将指向的目录修改为projects目录,因此,最终path指向another-project目录。
411         
412         
413         //Path 的normalize()方法可以标准化路径。
414         String originalPath =
415                  "d:\data\projects\a-project\..\another-project";
416 
417         Path path3 = Paths.get(originalPath);
418         System.out.println("path3 = " + path3);
419 
420         Path path2 = path3.normalize();
421         System.out.println("path2 = " + path2);
422         //如你所见,标准化后的路径不再包含 a-project..部分,因为它是多余的。
423         
424         //Files.exists()
425         //Files.exists()方法用来检查文件系统中是否存在某路径。
426         //Path实例对应的路径可能在文件系统中并不存在。例如,如果打算新建一个文件夹,首先需要创建一个对应的Path实例,然后才能创建对应路径下的文件夹。
427         //因为Path实例对应的路径在文件系统的存在性不确定,可以使用Files.exists()方法确认Path对应的路径是否存在 (也就是开发需要自己显式的去调用该方法确认)。
428         //如下是Files.exists()的示例:
429         Path path5 = Paths.get("data/logging.properties");
430 
431         boolean pathExists = Files.exists(path, new LinkOption[] { LinkOption.NOFOLLOW_LINKS });
432         System.out.println(pathExists);
433         //示例中首先创建了一个Path。然后,通过调用Files.exists方法并将path作为第一个参数确认path对应的路径是否存在。
434         //注意下Files.exist()方法的第二个参数。第二个参数数组是评判路径是否存在时使用的规则。
435         //示例中,数组包含LinkOption.NOFOLLOW_LINKS枚举类型,表示Files.exists不会跟进到路径中有连接的下层文件目录。
436         //表示path路径中如果有连接,Files.exists方法不会跟进到连接中去
437     }
438     
439     private void byteBufferUtf8() throws Exception {
440         Charset charset = null;
441         CharsetDecoder decoder = null;
442         String charsetName = "UTF-8";
443         int capacity = 10;
444 
445         charset = Charset.forName(charsetName);
446         decoder = charset.newDecoder();
447 
448         String s = "客户端发送dsad德生科技电脑fdas上考虑迪士尼年少弗拉门发生ofjam打什么的即破发麦克 ‘;打, 饭哦按asdfasfsdfdfsfdsf都客户端发送dsad德生科技电脑fdas上考虑迪士尼年少弗拉门发生ofjam打什么的即破发麦克 ‘;打, 饭哦按asdfasfsdfdfsfdsf都客户端发送dsad德生科技电脑fdas上考虑迪士尼年少弗拉门发生ofjam打什么的即破发麦克 ‘;打, 饭哦按asdfasfsdfdfsfdsf都客户端发送dsad德生科技电脑fdas上考虑迪士尼年少弗拉门发生ofjam打什么的即破发麦克 ‘;打, 饭哦按asdfasfsdfdfsfdsf都";
449         byte[] bytes = s.getBytes(charsetName);
450 
451         // 模拟接收的ByteBuffer size 10
452         ByteBuffer byteBuffer = ByteBuffer.allocate(capacity);
453         // 用于临时存放Bytebuffer转换后的字符
454         CharBuffer charBuffer = CharBuffer.allocate(capacity);
455         // 用于连接展示字符串
456         StringBuilder sb = new StringBuilder();
457 
458         int i = 0;
459         while (true) {
460             byteBuffer.put(bytes[i]);
461             i++;
462             if (byteBuffer.remaining() == 0 || i == bytes.length) {
463                 byteBuffer.flip();
464                 CoderResult coderResult;
465                 if (i != bytes.length) {
466                     coderResult = decoder.decode(byteBuffer, charBuffer, false);
467                 } else {
468                     coderResult = decoder.decode(byteBuffer, charBuffer, true);
469                 }
470                 // 有错误
471                 if (coderResult.isError()) {
472                     coderResult.throwException();
473                 }
474                 charBuffer.flip();
475                 sb.append(charBuffer);
476                 charBuffer.clear();
477                 byteBuffer.compact();
478             }
479             // 退出循环
480             if (i == bytes.length) {
481                 break;
482             }
483         }
484         System.out.println(sb);
485     }
486 }