google 了一晚上,終于找到了比較滿意的方法,下面是整個的 RedisCacheConfig 文件
@Configuration
public class RedisCacheConfig {
@Bean
public KeyGenerator simpleKeyGenerator() {
return (o, method, objects) -> {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(o.getClass().getSimpleName());
stringBuilder.append(".");
stringBuilder.append(method.getName());
stringBuilder.append("[");
for (Object obj : objects) {
stringBuilder.append(obj.toString());
}
stringBuilder.append("]");
return stringBuilder.toString();
};
}
@Bean
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
return new RedisCacheManager(
RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory),
this.getRedisCacheConfigurationWithTtl(600), // 默認策略,未配置的 key 會使用這個
this.getRedisCacheConfigurationMap() // 指定 key 策略
);
}
private Map<String, RedisCacheConfiguration> getRedisCacheConfigurationMap() {
Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
redisCacheConfigurationMap.put("UserInfoList", this.getRedisCacheConfigurationWithTtl(3000));
redisCacheConfigurationMap.put("UserInfoListAnother", this.getRedisCacheConfigurationWithTtl(18000));
return redisCacheConfigurationMap;
}
private RedisCacheConfiguration getRedisCacheConfigurationWithTtl(Integer seconds) {
Jackson2JsonRedisSerializer<Object> 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);
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
redisCacheConfiguration = redisCacheConfiguration.serializeValuesWith(
RedisSerializationContext
.SerializationPair
.fromSerializer(jackson2JsonRedisSerializer)
).entryTtl(Duration.ofSeconds(seconds));
return redisCacheConfiguration;
}
}
要指定 key 的過期時間,只要在getRedisCacheConfigurationMap方法中添加就可以。
然后只需要 @Cacheable 就可以把數(shù)據(jù)存入 redis
@Cacheable(value = "UserInfoList", keyGenerator = "simpleKeyGenerator") // 3000秒
@Cacheable(value = "UserInfoListAnother", keyGenerator = "simpleKeyGenerator") // 18000秒
@Cacheable(value = "DefaultKeyTest", keyGenerator = "simpleKeyGenerator") // 600秒,未指定的key,使用默認策略
router 是否使用 vue-router 的模式,啟用該模式會在激活導航時以 index 作為 path 進行路由跳轉(zhuǎn)
把這個屬性設置成true
element官網(wǎng)
其實直接
print(p1);
就可以
你代碼中的外部變量是,大寫的 Vue 和 Router
我在 stack overflow 找到了前人問題程答案:
https://stackoverflow.com/que...
"When an 'r' or 'R' prefix is present, a character following a backslash is included in the string without change, and all backslashes are left in the string. ......."
上面錯誤已刪
已作修改:
所以我想,可能因為在r''中,反斜杠后面的 ' 被當作字符保留了而且是一般字符,因而是失去了功能。
又或者是因為,例如r"abc" , 先生成"abc" 字符串,然後才加上r再處理, 如果r"反斜杠"就出現(xiàn)生成字符串失敗。
Doc. Python 里面建意r"反斜杠""
抱歉,反斜杠不見了,希望你
https://docs.python.org/2.0/r...
Doc.python 有陳述
已解決。
@Configuration
@EnableResourceServer
public class ResourceServerConfiguration
extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.requestMatchers()
.antMatchers("/api/**")
.and()
.authorizeRequests()
.antMatchers("/api/**")
.authenticated();
}
}使用Promise進行對APP.js內(nèi)的進行l(wèi)ogin的方法進行一次封裝后,在index.js內(nèi)調(diào)用app內(nèi)封裝的那個方法后拿到所需值然后對全局的那個globalData進行賦值,如果還有不明白的 明天到公司 我給你上代碼。
批量插入啊, 一次1000條
executemany
Object.prototype.__proto__,事實證明可以使用
function ClassA(name) {
this.name = name
}
ClassA.prototype.sayName = function () {
alert(this.name)
}
function ClassB(name, age) {
ClassA.call(this, name)
this.age = age
}
ClassB.prototype.__proto__ = ClassA.prototype
ClassB.prototype.sayAge = function () {
alert(this.age)
}
let instance = new ClassB('小明', 11)
instance.sayName(); //小明
instance.sayAge(); //11css里加個class,就比如叫.stop-click吧。樣式:
.stop-click {
pointer-events: none;
}
<view wx:for='{{logs.src}}'>
<image src="https://yffice.com{{logs.src[index]}}" class="slide-image" />
</view>
這樣寫就可以了把canvas和div放在一個節(jié)點下面
這樣看,a聲明了,但沒有定義
var a;
console.log(a); // undefined
console.log(b); // b 沒有聲明
b = 10;
a = 20;
看官方文檔,鏈接在此https://cn.vuejs.org/v2/guide...
func()?哪來的func()?能不能把你的代碼補充完整,包括你在哪里用了this,并且把你期望這個this指向哪個對象也補上。我猜你可能用了箭頭函數(shù),箭頭函數(shù)沒有this關(guān)鍵字哦。
我試了一下以下代碼(手機上只有node,node的原型是__proto__。瀏覽器上跑不方便)
function Graph() {}
var Graph = new Graph();
Graph.__proto__.foo = function() {
console.log('old foo', this);
return this;
}
Graph.__proto__.fun = function() {
console.log('old fun', this);
return this;
}
Graph.__proto__.foo = function() {
console.log('new foo', this);
function subfoo() {
console.log('subfoo', this);
this.fun();
return this;
}
subfoo.call(this);
return this;
}
Graph.foo();
結(jié)果是
new foo Graph {}
subfoo Graph {}
old fun Graph {}
Graph {}
非常的正常,不知道你有沒有漏了什么信息沒有提供的,當然也有可能是瀏覽器和node的差別。另外你在什么瀏覽器上測試的?我中午或下午可以在瀏覽器上測試一下。
比如
document.body.innerHTML='<img /><img />'
一個被作為img元素 一個作為字符串顯示
你就把相關(guān)的容器直接start不就好了嗎。
rxjs唄,你需要哪個導哪個
(function(){
var foo = "x";
(function(a){
a="y";
})(foo);
return foo;
})();
你那個等價于這個 這樣應該易懂一點吧
你看一下這兩個文件差異不就知道了嗎。
<link rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">北大青鳥APTECH成立于1999年。依托北京大學優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
達內(nèi)教育集團成立于2002年,是一家由留學海歸創(chuàng)辦的高端職業(yè)教育培訓機構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
北大課工場是北京大學校辦產(chǎn)業(yè)為響應國家深化產(chǎn)教融合/校企合作的政策,積極推進“中國制造2025”,實現(xiàn)中華民族偉大復興的升級產(chǎn)業(yè)鏈。利用北京大學優(yōu)質(zhì)教育資源及背
博為峰,中國職業(yè)人才培訓領(lǐng)域的先行者
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責任公司從事總經(jīng)理職務負責iOS教學及管理工作。
浪潮集團項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風格 授課風格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。