上一页 1 ··· 16 17 18 19 20
摘要: 多个环境下的配置应该怎么进行,比如数据库连接字符,多个环境不同,spring的方案,大概总结如下。 例子,数据库配置。 定义一个获取数据库链接的接口 分别有dev和prod两个实现 测试: 结果: 在本例中导入的是dev的配置 阅读全文
posted @ 2019-11-25 22:56 xuan_wu 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 一,问题,Bean找不到 代码 测试代码 虽然DemoClass打了@Component注解,但是在测试代码中@Autowired是找不到到,因为DemoClass是没有被Spring装配到容器中。 Spring把Bean装配到容器主要有以下几种方式 二、通过代码方式 @Configuration注 阅读全文
posted @ 2019-11-24 20:30 xuan_wu 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 通过spring提供的RestTemplate就可以访问rest服务。首先需要创建一个RestTemplate,这个需要手动来创建bean 需要说明的是,这里使用SimpleClientHttpRequestFactory ,是为了可以设置一些参数等,也可以直接new。 先设计一个返回list的re 阅读全文
posted @ 2019-11-14 23:36 xuan_wu 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 1.创建基于get参数的rest服务 2.创建向服务器post数据的rest服务 阅读全文
posted @ 2019-11-13 23:09 xuan_wu 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Spring系列第一篇,先通过Spring实现一个Hello Spring程序。 阅读全文
posted @ 2019-11-10 22:09 xuan_wu 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 引入actuator后发现 health可以正常展示。 但是发现beans无法展示 解决: 在application.properties里面加入配置: 阅读全文
posted @ 2019-11-10 15:34 xuan_wu 阅读(418) 评论(0) 推荐(0) 编辑
摘要: public static Properties loadProps(String fileName) { Properties properties = null; InputStream inputStream = null; try { inputStream = Thread.currentThread().g... 阅读全文
posted @ 2019-09-01 17:01 xuan_wu 阅读(420) 评论(0) 推荐(0) 编辑
摘要: 参数明细 查看大图 ThreadPoolExecutor执行顺序: 线程池按以下行为执行任务 当线程数小于核心线程数时,创建线程。 当线程数大于等于核心线程数,且任务队列未满时,将任务放入任务队列。 当线程数大于等于核心线程数,且任务队列已满 若线程数小于最大线程数,创建线程 若线程数等于最大线程数 阅读全文
posted @ 2019-08-19 23:22 xuan_wu 阅读(692) 评论(0) 推荐(0) 编辑
摘要: 线程池的好处 线程池主要处理流程 线程池的创建 使用ThreadPoolExecutor来创建,专门写一篇介绍。 线程池的配置 在《Java Concurrency in Practice》一书中,给出了估算线程池大小的公式: Nthreads = Ncpu x Ucpu x (1 + W/C),其 阅读全文
posted @ 2019-08-18 21:25 xuan_wu 阅读(363) 评论(0) 推荐(0) 编辑
摘要: 模拟一个ConnectionDriver,用于创建Connection package tread.demo.threadpool; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import 阅读全文
posted @ 2019-08-18 20:15 xuan_wu 阅读(1808) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20