SpringBoot2.5.1+Mybatis-Plus3.4.3:(Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required)


項目引發這個問題:
Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

  	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.1</version>
        <relativePath/>
    </parent>
    <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.3</version>
    </dependency>

事故原因:之前還是好好地運行,結果加入了redis-seesion就變成這樣了
上網百度:一大片的都是一下方案:
1.mybatis-plus版本問題.
2.加入druid的依賴

    <dependency>
    			<groupId>com.alibaba</groupId>
    			<artifactId>druid-spring-boot-starter</artifactId>
    			<version>1.2.9</version>
    		</dependency>

3.去除數據源自動注入的

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

我一想,這個我項目本身就是用了druid依賴,而且這個版本的我之前運行過沒問題呀
一定是使用redis-session這個依賴搞出的問題》
查看項目這個依賴,感覺沒問題呀。。。

 <!--session共享替換為redis-->
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-data-redis</artifactId>
  </dependency>

一想Springboot集成redis-session不可能是現在才有的,很早之前就有了,不可能沒有啟動器呀。於是加上一個這個啟動器試一試

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

沒想到OK了
+++++++
忽然又發現一個問題,多環境下的Springboot的配置不起作用啊》》》
我這是Springboot2.5+;

spring:
  profiles:
    active: prod

這個找不到application-prod.yml;明明有啊
image

這樣寫

  config:
    activate:
      on-profile: "dev"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM