Home > Back-end >  Whether LettuceConnectionFactory for redis and springboot version limitation?
Whether LettuceConnectionFactory for redis and springboot version limitation?

Time:10-26

 @ Component 
@ Configuration
Public class RedisConfig {

Public LettuceConnectionFactory lettuceConnectionFactoryTest () {
Return new LettuceConnectionFactory (new RedisStandaloneConfiguration (6379) "127.0.0.1,");
}

Public JedisConnectionFactory jedisConnectionFactoryTest () {
Return new JedisConnectionFactory (new RedisStandaloneConfiguration (6379) "127.0.0.1,");
}

}


 
The @autowired
Private RedisConfig RedisConfig;

The @autowired
Private StringRedisTemplate redisTemplate;

@ Test
Public void test () {

RedisTemplate. SetConnectionFactory (redisConfig lettuceConnectionFactoryTest ());//for lettuce has been submitted to the null pointer exception
ValueOperations ValueOperations=redisTemplate. OpsForValue ();
ValueOperations. Set (" test ", "test123");
System. The out. Println (valueOperations. Get (" test "));

}

Why only jedisConnectionFactoryTest can pass the test, and has been submitted to the null pointer exception lettuceConnectionFactoryTest? Thank you, really appreciate.
Redis: 3.2.8
Springboot: 2.1.0. RELEASE
Jdk8

 Java. Lang. NullPointerException 
The at org. Springframework. Data. Redis. Connection. Lettuce. LettuceConnectionFactory $SharedConnection. GetNativeConnection (LettuceConnectionFactory. Java: 1085)
The at org. Springframework. Data. Redis. Connection. Lettuce. LettuceConnectionFactory $SharedConnection. GetConnection (LettuceConnectionFactory. Java: 1065)
The at org. Springframework. Data. Redis. Connection. Lettuce. LettuceConnectionFactory. GetSharedConnection (LettuceConnectionFactory. Java: 865)
The at org. Springframework. Data. Redis. Connection. Lettuce. LettuceConnectionFactory. GetConnection (LettuceConnectionFactory. Java: 340)
The at org. Springframework. Data. Redis. Core. RedisConnectionUtils. DoGetConnection (RedisConnectionUtils. Java: 132)
The at org. Springframework. Data. Redis. Core. RedisConnectionUtils. GetConnection (RedisConnectionUtils. Java: 95)
The at org. Springframework. Data. Redis. Core. RedisConnectionUtils. GetConnection (RedisConnectionUtils. Java: 82)
The at org. Springframework. Data. Redis. Core. RedisTemplate. Execute (RedisTemplate. Java: 211)
The at org. Springframework. Data. Redis. Core. RedisTemplate. Execute (RedisTemplate. Java: 184)
The at org. Springframework. Data. Redis. Core. AbstractOperations. Execute (AbstractOperations. Java: 95)
At org. Springframework. Data. Redis. Core. DefaultValueOperations. Set (236) DefaultValueOperations. Java:
At com. Test. Proceeds. InfrastructureApplicationTests. Test (InfrastructureApplicationTests. Java: 40)
At sun. Reflect. NativeMethodAccessorImpl. Invoke0 (Native Method)
At sun. Reflect. NativeMethodAccessorImpl. Invoke (NativeMethodAccessorImpl. Java: 62)
At sun. Reflect. DelegatingMethodAccessorImpl. Invoke (43) DelegatingMethodAccessorImpl. Java:
The at Java. Lang. Reflect. Method. Invoke (498) Method. The Java:
The at org. Junit. Runners. Model. FrameworkMethod $1. RunReflectiveCall (FrameworkMethod. Java: 50)
The at org. Junit. Internal. Runners. Model. ReflectiveCallable. Run (ReflectiveCallable. Java: 12)
The at org. Junit. Runners. Model. FrameworkMethod. InvokeExplosively (FrameworkMethod. Java: 47)
The at org. Junit. Internal. Runners. Statements. InvokeMethod. Evaluate (InvokeMethod. Java: 17)
The at org. Springframework. Test. The context. Takeup. Statements. RunBeforeTestExecutionCallbacks. Evaluate (RunBeforeTestExecutionCallbacks. Java: 74)
The at org. Springframework. Test. The context. Takeup. Statements. RunAfterTestExecutionCallbacks. Evaluate (RunAfterTestExecutionCallbacks. Java: 84)
The at org. Springframework. Test. The context. Takeup. Statements. RunBeforeTestMethodCallbacks. Evaluate (RunBeforeTestMethodCallbacks. Java: 75)
The at org. Springframework. Test. The context. Takeup. Statements. RunAfterTestMethodCallbacks. Evaluate (RunAfterTestMethodCallbacks. Java: 86)
The at org. Springframework. Test. The context. Takeup. Statements. SpringRepeat. Evaluate (SpringRepeat. Java: 84)
The at org. Junit. Runners. ParentRunner. RunLeaf (ParentRunner. Java: 325)
The at org. Springframework. Test. The context. Takeup. SpringJUnit4ClassRunner. RunChild (SpringJUnit4ClassRunner. Java: 251)
The at org. Springframework. Test. The context. Takeup. SpringJUnit4ClassRunner. RunChild (SpringJUnit4ClassRunner. Java: 97)
The at org. Junit. Runners. ParentRunner $3. The run (ParentRunner. Java: 290)
The at org. Junit. Runners. ParentRunner $1. The schedule (ParentRunner. Java: 71)
The at org. Junit. Runners. ParentRunner. RunChildren (ParentRunner. Java: 288)
The at org. Junit. Runners. ParentRunner. Access the $000 (ParentRunner. Java: 58)
At org. Junit. Runners. ParentRunner $2. The evaluate (ParentRunner. Java: 268)
The at org. Springframework. Test. The context. Takeup. Statements. RunBeforeTestClassCallbacks. Evaluate (RunBeforeTestClassCallbacks. Java: 61)
The at org. Springframework. Test. The context. Takeup. Statements. RunAfterTestClassCallbacks. Evaluate (RunAfterTestClassCallbacks. Java: 70)
The at org. Junit. Runners. ParentRunner. Run (ParentRunner. Java: 363)
The at org. Springframework. Test. The context. Takeup. SpringJUnit4ClassRunner. Run (SpringJUnit4ClassRunner. Java: 190)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related