1. 程式人生 > >ybatis問題:There is no getter for property named 'unitId' in 'class java.lang.String'

ybatis問題:There is no getter for property named 'unitId' in 'class java.lang.String'

開發十年,就只剩下這套架構體系了! >>>   

Mybatis遇到的問題

問題:

複製程式碼

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'unitId' in 'class java.lang.String'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371) at com.sun.proxy.$Proxy6.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy11.getUsersByUnitId(Unknown Source) at com.thinkPro.steap.db.base.sys.user.UserBase.getUsersByUnitId(UserBase.java:125) at com.thinkPro.steap.db.service.sys.user.UserService.getUsersByUnitId(UserService.java:188) at com.thinkPro.steap.test.TestUser.testGetUsersByUnitId(TestUser.java:184) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter
for property named 'unitId' in 'class java.lang.String' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:380) at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:170) at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:152) at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:48) at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116) at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:97) at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:116) at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657) at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210) at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210) at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:56) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210) at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333) at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:310) at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:45) at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32) at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:33) at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32) at org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply(TrimSqlNode.java:54) at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32) at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40) at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:75) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358) ... 32 more

複製程式碼

分析:

那麼什麼情況下會發生“There is no getter for property named in ‘class java.lang.String’”錯誤呢?

其實是在這種情況下:

複製程式碼

<select id="getRiskMember" resultMap="BaseResultMap" parameterType="String">
        <include refid="selectMember"/>
        and safetylevel > 1
        and stauts = 1

        <if test="username != null">
            and username = #{username} 
        </if>
    </select>

複製程式碼

注意看,是在if test=驗證的時候發生的 “There is no getter for property named in ‘class java.lang.String’”,

而並非是and username = #{username} 的時候發生的錯誤。

解決辦法:

複製程式碼

<select id="getRiskMember" resultMap="BaseResultMap" parameterType="String">
        <include refid="selectMember"/>
        and safetylevel > 1
        and stauts = 1

        <if test="_parameter != null">
            and username = #{username} 
        </if>
    </select>

複製程式碼

相關推薦

There is no getter for property named 'xxx' in 'class java.lang.String

code app select unknown cep proxy sun myba bat 報錯信息: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.

Mybatis異常There is no getter for property named 'XXX' in 'class java.lang.String'

for ava 異常 public rom title mpc mybatis string Mybatis版本:mybatis-3.0.6.jar 1.當入參為 string類型時 (包括java.lang.String.) 我們使用#{xxx}引入參數.會拋異

mybatis之org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'time' in 'class java.lang.String'

mybatis 圖片 配置 style pac prop bubuko type PE mybatis接口 List<String> getUsedCate(String time); 配置文件 <select id="getUsed

Mybatis中傳參包There is no getter for property named 'XXX' in 'class java.lang.String'

col mybatis hone mybatis查詢 默認 lec named ongl bsp Mybatis中傳參包There is no getter for property named ‘XXX‘ in ‘class java.lang.String‘ 一、發現

mybatis中報There is no getter for property named 'devName' in 'class java.lang.String‘的錯誤

今天在做一個新專案的時候,寫好了controller,service,dao層後,在xml檔案中寫sql,因為這個介面要使用名稱來模糊查詢,但是執行的時候傳入引數,卻報There is no getter for property named 'devName' in 'class java.l

SSM框架報錯分析(一)——There is no getter for property named 'XXX' in 'class java.lang.String'

一、發現問題 <select id="queryStudentByNum" resultType="student" parameterType="string"> select num,name,phone from student <where> <if t

mybatis 異常 There is no getter for property named 'bizId' in 'class java.lang.Long'

img 技術分享 .com mybatis lan alt nbsp pro 錯誤 mybatis 異常 There is no getter for property named ‘bizId‘ in ‘class java.lang.Long‘ 當使用mybatis進行

異常處理Mybatis報錯There is no getter for property named 'xxxx' in 'class xxx'

bat 變量 應該 img 分享 mybatis quest 情況 定義 /1、報錯信息: 2、根據報錯的信息,提示我們少了一個getter方法。那麽我們是不是真的就少了這個getter呢?這個時候更應該去檢查我們的model中是不是有某個詞寫錯了。因為當我們定義的這個變

mybatis 報錯There is no getter for property named 'XXX' in 'class com.xx.xx'

mybatis報錯資訊記錄: ### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ba

There is no getter for property named 'user' in 'class com.jyr.wh.domain.User' 異常

今天在使用mybatis時,出現了一個問題:There is no getter for property named 'user' in 'class com.jyr.wh.domain.User,現記錄下來 使用註解的形式寫sql語名,引數為一個物件 以下為正確寫法: @I

mybaits錯誤解決There is no getter for property named 'id' in class 'java.lang.String'

在使用mybaitis傳引數的時候,如果僅傳入一個型別為String的引數,那麼在 xml檔案中應該使用_parameter來代替引數名。 正確的寫法: <span style="font-size:18px;"> <!-- 用於查詢運單

MyBatis報錯There is no getter for property named 'xxx' in 'class java.lang.String'

在Mybatis的mapper檔案如果傳入的是一個字串型別的引數,且將該引數用來在<if test='"">判斷時,如果直接用引數名來判斷,則會報如標題所示的錯誤, 正確程式碼如下: &l

MyBatis的問題There is no getter for property named '資料表中的欄位名' in '實體類'!

在MyBaits中的配置檔案中:mybaits-config.xml中有這樣一句話:在程式碼中用紅色標註:<?xml version="1.0" encoding="UTF-8"?> <

Mybatis報錯There is no getter for property named 'xxxx' in 'class xxxx

在網上看見了不少的處理方法,可能每個人遇到的問題一樣,但是出問題的地方不一樣,我所遇到的這個問題,我是如下處理的。我在做JUnit測試的是時候報的這個錯誤,報錯如下:Caused by: org.apache.ibatis.reflection.ReflectionExcep

mybaits錯誤There is no getter for property named 'id' in class 'java.lang.String'

在使用mybaitis傳引數的時候,如果僅傳入一個型別為String的引數,那麼在 xml檔案中應該使用_parameter來代替引數名。 錯誤的寫法: <select id="isCargoBillNoExist" resultType="java.lang.In

There is no getter for property named 'XXX' in class 'aaa.bbb.ccc'(終極騷操作的解決方法)

rda col property pan 方法 style pack insert tro   使用SpringBoot整合Mybatis時,遇到了像標題的異常,博主當時是用Bean類對象作為參數的,所以百度了很久都沒有建設性答案。貼一下報錯的xxxDao文件和xxxMap

Springboot 出現ibatis:there is no getter for property named 'XX' in class XX的原因及解決辦法

目錄 Dao層書寫的過程中,對映的引數無法對應上。 Dao層書寫的過程中,對映的引數無法對應上。 比如在書寫Mapper層 @Select(“select * from XXX where XX =#{abc};”) 其中abc是Dao層ABC

解決JavaThere is no getter for property XXX'XXX' in 'class XXX'的問題

src 區分 全路徑 實體類 找到 16px 解決 區分大小寫 ont 當你出現There is no getter for property XXX‘XXX‘ in ‘class XXX‘時,    就是在你的這個類中沒有找到你這個屬性。 檢查兩個地方 1.你的返回值

There is no setter for property named 'dd_valueId' in 'class com.manager.pojo.DataDictionary'的錯誤解決方法

錯誤提示我在 class com.manager.pojo.DataDictionary這個實體類裡沒有屬性’dd_valueId’的setter方法 DataDictionary程式碼 我拉下去看了,所有的欄位都是有get和set方法的 MyBatis對映檔案程