![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java
不夜城的油条
这个作者很懒,什么都没留下…
展开
-
抽象类的单例模式
/* * 单例模式 * 建立在类加载时,所以天生对多线程友好 */public class SingleInstance { private SingleInstance() { System.out.println("is create"); } private static class SingleHolder { ...原创 2017-11-09 19:43:59 · 266 阅读 · 0 评论 -
Spring Cloud项目启动,Tomcat报端口已被使用
因为用feign,所以引用了另一个Spring Cloud项目。而另外一个项目的server.port写在application.properties中。替换了本地项目的配置文件。把另外一个项目server.port写在bootstrap.properties中。再次引用,问题解决。...原创 2017-11-09 09:53:03 · 1435 阅读 · 0 评论 -
Spring使用DeferredResult实现长连接
@RestController@RequestMapping("/notifications")public class NotificationResource implements ReleaseMessageListener { private static final Logger logger = LoggerFactory.getLogger(NotificationRe...原创 2018-11-15 16:00:46 · 4969 阅读 · 1 评论 -
Spring Cloud使用BootstrapConfiguration配置启动加载项
使用BootstrapConfiguration加载,等同于bootstrap.yml中的配置使用PropertySourceLocator接口@Configurationpublic class BootstrapConfigurer implements PropertySourceLocator { private static final Logger log = L...原创 2018-11-15 16:11:42 · 14411 阅读 · 1 评论 -
Spring使用EnvironmentPostProcessor自定义启动配置项
public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor { private static final String PROPERTY_SOURCE_NAME = "defaultProperties"; @Override public void postProcessEn...原创 2018-11-15 16:37:45 · 7419 阅读 · 0 评论 -
使用WebAsyncTask与Callable实现异步Http接口
1.实现一个接口@RestControllerpublic class LocalController { private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); @RequestMapping("/ac") public WebAsyncTas...原创 2018-11-15 17:36:30 · 1357 阅读 · 0 评论 -
RateLimiter做限流
<dependency> <groupId>com.google.inject.extensions</groupId> <artifactId>guice-multibindings</artifactId> <version>RELEASE</version></dep原创 2018-11-26 14:41:10 · 245 阅读 · 0 评论 -
Java深拷贝
public class DeepCopy { public static Object copy(Object orig) throws NotSerializableException { Object obj = null; try { // Write the object out to a byte array ...原创 2018-11-27 17:39:51 · 205 阅读 · 0 评论