小编Swi*_*nky的帖子

TS-2304 错误 - 在“.ts”文件中导入“jquery”时在 TypeScript 中找不到名称“Iterable”

我正在使用 Visual Studio Code 作为编辑器开发 TypeScript 2.4 版。我使用以下命令安装了带有 NPM 的 jQuery:

npm install --save @types/jquery
Run Code Online (Sandbox Code Playgroud)

然后我jquery moduleGitHub下载了 的源代码。

registrationpage.ts文件代码如下:

import * as $ from 'jquery';
class Registration_Page {
    txtuname: string;
    Registration() {
        $('#table').hide;
        this.txtuname = ( <HTMLTextAreaElement> (document.getElementById('txtusername'))).value;
    }
}
window.onload = () => {
    $('#table').show;
    var bttnLogin = document.getElementById('submit');
    var obj = new Registration_Page();
    bttnLogin.onclick = function () {
        obj.Registration();
    }
}
Run Code Online (Sandbox Code Playgroud)

代码index.html如下:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="registrationpage.js"></script>

</head> …
Run Code Online (Sandbox Code Playgroud)

jquery node.js npm typescript

5
推荐指数
1
解决办法
3113
查看次数

带有 Jedis 连接工厂、Redis 独立配置和多线程的 Spring Redis 模板

我在多线程环境中使用 Spring Redis 模板。一个线程将数据保存到 Redis 中,另一个线程(调度程序)从中获取数据。JedisConnectionFactory 用于 redis 模板。以下是获取redis连接的代码片段:

JedisConnectionFactory jedisConnectionFactory() {

    JedisConnectionFactory jedisConnectionFactory = null;

    try {
        RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(hostName,
                port);
        jedisConnectionFactory = new JedisConnectionFactory(redisStandaloneConfiguration);
    } catch (RedisConnectionFailureException e) {
        LOGGER.error("Connection break with redis " + e.getMessage());
    }

    return jedisConnectionFactory;
}

/**
 * Redis template.
 *
 * @return the redis template
 */
@Bean
public RedisTemplate<String, Object> redisTemplate() {
    final RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
    template.setConnectionFactory(jedisConnectionFactory());
    template.setValueSerializer(new GenericToStringSerializer<Object>(Object.class));
    template.setEnableTransactionSupport(true);
    return template;
}
Run Code Online (Sandbox Code Playgroud)

redis模板的实例是通过构造函数自动连线获取的,如下:

@Autowired
public A(RedisTemplate<String, …
Run Code Online (Sandbox Code Playgroud)

multithreading redis resttemplate jedis spring-boot

4
推荐指数
1
解决办法
8421
查看次数