idea license 可用

地址: https://blog.csdn.net/weixin_37264997/article/details/89846698

springboot application.yml配置integer变量

参考: https://blog.csdn.net/blueheart20/article/details/81480864


Failed to bind properties under 'dubbo.protocol.port' to java.lang.Integer:

    Property: dubbo.protocol.port
    Value: (java.lang.Integer)${server.port}
    Origin: class path resource [application.yml]:136:11
    Reason: failed to convert java.lang.String to java.lang.Integer

这些变量字符在进行maven的clean install的时候回替换成对应的变量,可以通过执行maven的clean install命令后采用解压缩包打开对应的war查看 对应的application.yml中的配置,会发现里面的变量已经被替换。 在pom.xml中进行如下配置:

 <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
</resources>

Cacheable注解

  • org.springframework.cache.interceptor.CacheInterceptor

  • org.springframework.cache.interceptor.CacheInterceptor#invoke

  • org.springframework.cache.interceptor.CacheAspectSupport#execute(org.springframework.cache.interceptor.CacheOperationInvoker, java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

  • org.springframework.cache.interceptor.CacheAspectSupport#execute(org.springframework.cache.interceptor.CacheOperationInvoker, java.lang.reflect.Method, org.springframework.cache.interceptor.CacheAspectSupport.CacheOperationContexts)

核心代码

        if (contexts.isSynchronized()) {
			CacheOperationContext context = contexts.get(CacheableOperation.class).iterator().next();
			if (isConditionPassing(context, CacheOperationExpressionEvaluator.NO_RESULT)) {
				Object key = generateKey(context, CacheOperationExpressionEvaluator.NO_RESULT);
				Cache cache = context.getCaches().iterator().next();
				try {
					return wrapCacheValue(method, cache.get(key, () -> unwrapReturnValue(invokeOperation(invoker))));
				}
				catch (Cache.ValueRetrievalException ex) {
					// The invoker wraps any Throwable in a ThrowableWrapper instance so we
					// can just make sure that one bubbles up the stack.
					throw (CacheOperationInvoker.ThrowableWrapper) ex.getCause();
				}
			}
			else {
				// No caching required, only call the underlying method
				return invokeOperation(invoker);
			}
		}

进入redis中的缓存获取:org.springframework.data.redis.cache.RedisCache#get,这个是redis与数据库封装的类,还有参考类: org.springframework.cache.support.AbstractValueAdaptingCache#get(java.lang.Object) 这个是redis的相关操作类

    public synchronized <T> T get(Object key, Callable<T> valueLoader) {

		ValueWrapper result = get(key);

		if (result != null) {
			return (T) result.get();
		}

		T value = valueFromLoader(key, valueLoader);
		put(key, value);
		return value;
	}

最后更新: 6/29/2019, 7:56:34 PM
本文浏览量