国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

解決問題 Could not obtain transaction-synchronized Session for current thread

這篇具有很好參考價值的文章主要介紹了解決問題 Could not obtain transaction-synchronized Session for current thread。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、問題現(xiàn)象

在使用Hibernate的項目中,在一個定時任務(wù)中,執(zhí)行某段代碼,滿足條件后,更新表數(shù)據(jù)。

程序在執(zhí)行到更新表數(shù)據(jù)的時候,報錯如下:

Could not obtain transaction-synchronized Session for current thread

解決問題 Could not obtain transaction-synchronized Session for current thread


二、解決方案

spring-config.xml 配置事務(wù) 切入點切入方法

<!-- 配置事務(wù)管理 -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    <!-- 指定使用cglib -->
     <aop:aspectj-autoproxy proxy-target-class="true" />
    <!-- 配置事務(wù)的傳播特性 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="dispose*" propagation="REQUIRED" />
        </tx:attributes>
    </tx:advice>

    <!-- 配置事務(wù)的切入點 -->
    <aop:config>
        <aop:pointcut id="targetMethodSchedule" expression="execution(* com.miracle.luna.mock.schedule.*.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="targetMethodSchedule" />
    </aop:config>

[說明]
1、<tx:method name=“dispose*” propagation=“REQUIRED” /> 表示對dispose 開頭的方法有效;
2、<aop:pointcut id=“targetMethodSchedule” expression=“execution(* com.miracle.luna.mock.schedule..(…))” /> 可以模糊匹配 schedule 目錄下的多個服務(wù)層。

注意此處,不管schedule目錄下有沒有細分 service 和 impl層,必須是 schedule..(…)) ,否則會報如下錯誤。

Caused by: java.lang.IllegalArgumentException: warning no match for this type name: com.miracle.luna.mock.schedule [Xlint:invalidAbsoluteTypeName]
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:315)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:217)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:190)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:169)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:220)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:279)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:311)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:119)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:89)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:70)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:346)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:298)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    ... 149 more

解決問題 Could not obtain transaction-synchronized Session for current thread文章來源地址http://www.zghlxwxcb.cn/news/detail-477513.html


到了這里,關(guān)于解決問題 Could not obtain transaction-synchronized Session for current thread的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Mac Could not find the GDAL library 問題解決

    https://docs.djangoproject.com/en/5.0/ref/contrib/gis/install/#macos 蘋果系統(tǒng) Mac 中搭建 GeoDjango 開發(fā)環(huán)境時出現(xiàn)以下報錯: 找到 libgdal.dylib 的路徑 settings.py 中添加以下代碼: 找到 libgeos_c.dylib 的路徑 settings.py 中添加以下代碼:

    2024年01月21日
    瀏覽(34)
  • 單元測試 報 Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions

    ?單元測試: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the se

    2024年02月06日
    瀏覽(24)
  • Git錯誤解決:如何處理“could not determine hash algorithm“問題

    Git錯誤解決:如何處理“could not determine hash algorithm“問題

    ???? 博主貓頭虎(????)帶您 Go to New World??? ?? 博客首頁 ——????貓頭虎的博客?? ?? 《面試題大全專欄》 ?? 文章圖文并茂??生動形象??簡單易學!歡迎大家來踩踩~?? ?? 《IDEA開發(fā)秘籍專欄》 ?? 學會IDEA常用操作,工作效率翻倍~?? ?? 《100天精通Golang(基礎(chǔ)

    2024年02月03日
    瀏覽(35)
  • Could not initialize class org.bytedeco.javacpp.avutil問題解決

    最近提供需要提供音視頻服務(wù)。參考網(wǎng)上的開源程序,提供了一個JAVA版的RTSP轉(zhuǎn)HTTP的服務(wù),并使用ffmpeg作為播放工具。 該程序在自己的機器上沒有問題,但生成jar包后放置到服務(wù)器上運行出錯,出錯的是“java.lang.NoClassDefFoundError:Could not initialize class org.bytedeco.ffmpeg.gl

    2024年02月13日
    瀏覽(25)
  • 【筆記】解決Ubuntu 23.04下Warning: Could not find TensorRT的問題

    1. 有一塊quadro顯卡,想要試用一下, 先使用conda list安裝了tensorflow 和 tensorrt 代碼: import tensorflow as tf print(tf.test.is_built_with_cuda()) print(tf.config.list_physical_devices(\\\'GPU\\\')) 遇到如下問題: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT True W tensorflow/core/co

    2024年02月07日
    瀏覽(28)
  • 已解決 IDEA Maven 項目中 “Could not find artifact“ 問題的常見情況和解決方案

    已解決 IDEA Maven 項目中 “Could not find artifact“ 問題的常見情況和解決方案

    ???? 博主 libin9iOak帶您 Go to New World.??? ?? 個人主頁——libin9iOak的博客?? ?? 《面試題大全》 文章圖文并茂??生動形象??簡單易學!歡迎大家來踩踩~?? ?? 《IDEA開發(fā)秘籍》學會IDEA常用操作,工作效率翻倍~?? ???? 希望本文能夠給您帶來一定的幫助??文章粗淺,敬

    2024年02月11日
    瀏覽(28)
  • IDEA Maven 項目中 “Could not find artifact“ 問題的常見情況和解決方案

    在IDEA(IntelliJ IDEA)中使用Maven構(gòu)建項目時,有時會遇到“Could not find artifact”這樣的錯誤。這個錯誤通常意味著Maven試圖下載或查找某個依賴項,但是沒有在配置的倉庫中找到。這個問題可能會導(dǎo)致項目構(gòu)建失敗,因此需要了解常見的情況以及相應(yīng)的解決方案。 IDEA Maven項目中

    2024年04月26日
    瀏覽(120)
  • 虛幻引擎圖文筆記:could not be compiled. Try rebuilding from source manually.問題的解決

    虛幻引擎圖文筆記:could not be compiled. Try rebuilding from source manually.問題的解決

    從SVN上Checkout的必要文件,在其它電腦上構(gòu)建過一次沒有問題,結(jié)果到了這臺比較新的電腦上出現(xiàn)了如下問題?: 嘗試生成sln文件?: 彈出了如下提示?: 在.NET Core官網(wǎng)下載并安裝.NET Core。 于是又出現(xiàn)了如下提示 在這里下載并安裝framework的指定版本,我這里要求安裝 3.1.

    2024年02月11日
    瀏覽(25)
  • Android Studio 解決Could not resolve com.android.tools.build:gradle:7.4.2問題

    Android Studio 解決Could not resolve com.android.tools.build:gradle:7.4.2問題

    A problem occurred configuring root project \\\'MyApplication2\\\'. Could not resolve all files for configuration \\\':classpath\\\'. ?? Could not resolve com.android.tools.build:gradle:7.4.2. ?? ? Required by: ?? ? ? ? project : com.android.application:com.android.application.gradle.plugin:7.4.2 ?? ? ? ? project : com.android.library:com.android.library.

    2024年02月01日
    瀏覽(128)
  • 解決Could not load dynamic library ‘cudnn64_8.dll‘; dlerror: cudnn64_8.dll not found問題

    解決Could not load dynamic library ‘cudnn64_8.dll‘; dlerror: cudnn64_8.dll not found問題

    以前都是在用CPU跑深度學習,只能說太勇了,今天終于想通了用GPU跑代碼。 搭建環(huán)境參考 全網(wǎng)最詳細的深度學習tensorflow-gpu環(huán)境配置 這篇文章寫得非常棒,在運行的時候出現(xiàn)了報錯 Could not load dynamic library ‘cudnn64_8.dll’; dlerror: cudnn64_8.dll not found 這個報錯應(yīng)該就是下載的cu

    2023年04月08日
    瀏覽(20)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包