/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.2.RELEASE)
2018-05-30 10:03:51.252 INFO 6448 --- [ restartedMain] com.example.DemoApplication : Starting DemoApplication on huyh-PC with PID 6448 (D:\work\springbootspace\demo\target\classes started by huyh in D:\work\springbootspace\demo)
2018-05-30 10:03:51.254 INFO 6448 --- [ restartedMain] com.example.DemoApplication : No active profile set, falling back to default profiles: default
2018-05-30 10:03:51.775 INFO 6448 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5d4441ea: startup date [Wed May 30 10:03:51 CST 2018]; root of context hierarchy
2018-05-30 10:03:53.404 WARN 6448 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.example]' package. Please check your configuration.
2018-05-30 10:03:53.509 INFO 6448 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2018-05-30 10:03:54.092 INFO 6448 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$5cc6f725] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-05-30 10:03:54.107 INFO 6448 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cache.annotation.ProxyCachingConfiguration' of type [org.springframework.cache.annotation.ProxyCachingConfiguration$$EnhancerBySpringCGLIB$$a5d92d43] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-05-30 10:03:54.840 INFO 6448 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-05-30 10:03:54.885 INFO 6448 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-05-30 10:03:54.885 INFO 6448 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-05-30 10:03:54.890 INFO 6448 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\work\JDK\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\work\JDK\bin;D:\work\SVN\bin;C:\Program Files (x86)\Git\cmd;%TOMCAT_HOME%\bin;D:\work\tomcat7\lib;D:\work\JDK\bin;D:\work\JDK\jre\bin;.]
2018-05-30 10:03:55.634 INFO 6448 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-05-30 10:03:55.634 INFO 6448 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3864 ms
2018-05-30 10:03:56.250 INFO 6448 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-05-30 10:03:56.259 INFO 6448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-05-30 10:03:56.260 INFO 6448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-05-30 10:03:56.261 INFO 6448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-05-30 10:03:56.262 INFO 6448 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
2018-05-30 10:03:56.854 WARN 6448 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisCacheTransfer': Unsatisfied dependency expressed through method 'setJedisConnectionFactory' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2018-05-30 10:03:56.869 INFO 6448 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-05-30 10:03:56.885 INFO 6448 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-05-30 10:03:57.077 ERROR 6448 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method setJedisConnectionFactory in com.example.Utils.cache.RedisCacheTransfer required a bean of type 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory' that could not be found.
- Bean method 'redisConnectionFactory' in 'JedisConnectionConfiguration' not loaded because @ConditionalOnMissingBean (types: org.springframework.data.redis.connection.RedisConnectionFactory; SearchStrategy: all) found beans of type 'org.springframework.data.redis.connection.RedisConnectionFactory' redisConnectionFactory
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory' in your configuration.
Process finished with exit code 0
剛接觸spring boot在用redis做二級緩存的時候,依照往上的例子做的,結(jié)果啟動的時候就報這個錯誤!
pom依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
然后下面是application的
#redis
spring.redis.database=1
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=0
spring.redis.pool.max-active=8
spring.redis.pool.max-wait=-1
spring.redis.timeout=50000
#數(shù)據(jù)庫配置
mybatis.mapperLocations=classpath:mappers/*.xml
mybatis.type-aliases-package= com.example.entity
mybatis.config-location= classpath:mybatis-config.xml
#全局映射器啟用緩存 *主要將此屬性設(shè)置完成即可
mybatis.cacheEnabled=true
#查詢時,關(guān)閉關(guān)聯(lián)對象即時加載以提高性能
mybatis.lazyLoadingEnabled=false
#對于未知的SQL查詢,允許返回不同的結(jié)果集以達到通用的效果
mybatis.multipleResultSetsEnabled=true
#設(shè)置關(guān)聯(lián)對象加載的形態(tài),此處為按需加載字段(加載字段由SQL指 定),不會加載關(guān)聯(lián)表的所有字段,以提高性能
mybatis.aggressiveLazyLoading=true
#pagehelper
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
spring.datasource.url = jdbc:mysql://localhost:3306/exam
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.driverClassName =com.mysql.jdbc.Driver
spring.datasource.max-active=20
spring.datasource.max-idle=8
spring.datasource.min-idle=8
spring.datasource.initial-size=10
報錯類
@Component
public class RedisCacheTransfer {
@Autowired
public void setJedisConnectionFactory(JedisConnectionFactory jedisConnectionFactory) {
MybatisRedisCache.setJedisConnectionFactory(jedisConnectionFactory);
}
}
然后啟動的時候就是這個錯
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method setJedisConnectionFactory in com.example.Utils.cache.RedisCacheTransfer required a bean of type 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory' that could not be found.
- Bean method 'redisConnectionFactory' in 'JedisConnectionConfiguration' not loaded because @ConditionalOnMissingBean (types: org.springframework.data.redis.connection.RedisConnectionFactory; SearchStrategy: all) found beans of type 'org.springframework.data.redis.connection.RedisConnectionFactory' redisConnectionFactory
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory' in your configuration.
Process finished with exit code 0
我也不知道我貼的這些夠不夠大佬們分析問題,如果想看哪里我可以再貼上來
不知在該類中是否有JedisConnectionFactory變量,其實如果你使用了@Component注解了之后,你可以直接在該類中直接使用@AutoWired直接注入
@Component
public class RedisCacheTransfer {
@Autowired
private JedisConnectionFactory jedisConnectionFactory
}
這樣寫不是更加優(yōu)美?
如果你想將該類注冊到MybatisRedisCache中進行設(shè)置,則你可以在你的conifg文件中,當SpringBoot啟動的時候在Mybatis配置方法中加入方法即可
原因如 @喵了個咪 所說,Spring-boot 2.0 默認使用redis client是lettuce
把JedisConnectionFactory依賴替換為org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory或者org.springframework.data.redis.connection.RedisConnectionFactory
推薦后者,它是JedisConnectionFactory和LettuceConnectionFactory都實現(xiàn)的接口,好處是哪天你想換個redis client可以只改項目依賴而不用動Java代碼
排除lettuce依賴,引入jedis
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
或者用spring-boot 1.x也可以
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團,成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達內(nèi)教育集團成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
浪潮集團項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負責(zé)iOS教學(xué)及管理工作。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。