嘗試用springmvc,mybatis,mysql做個工具平臺。 在本地mac筆記本上運行正常,但把包放置到伺服器上,啟動tomcat就報錯。類找不到了。 文件目錄: 實現需求:上傳文檔並記錄在資料庫中。自建了DocFile類。創建對應的mapper文件寫sql語句。 mapper.xml中nam ...
嘗試用springmvc,mybatis,mysql做個工具平臺。
在本地mac筆記本上運行正常,但把包放置到伺服器上,啟動tomcat就報錯。類找不到了。
文件目錄:
實現需求:上傳文檔並記錄在資料庫中。自建了DocFile類。創建對應的mapper文件寫sql語句。
mapper.xml中namespace是指向DocFileDao。
<mapper namespace="com.bbc_kit.operation.dao.DocFileDao"> <!-- namespace 需要和dao層的"包名+介面名"一致 --> <resultMap type="com.bbc_kit.operation.entities.DocFile" id="DocFileResult"> <id property="docFileId" column="docFileId" jdbcType="VARCHAR"/> <result property="docFileType" column="docFileType" jdbcType="VARCHAR"/> <result property="docFileName" column="docFileName" jdbcType="VARCHAR"/> <result property="docFilePath" column="docFilePath" jdbcType="VARCHAR"/> <result property="created_by" column="created_by" jdbcType="VARCHAR"/> <result property="date_created" column="date_created" jdbcType="DATE"/> <result property="updated_by" column="updated_by" jdbcType="VARCHAR"/> <result property="date_updated" column="date_updated" jdbcType="DATE"/> <result property="valiable" column="valiable" jdbcType="VARCHAR"/> </resultMap> <select id="queryOptDocFile" parameterType="HashMap" resultMap="DocFileResult"> select * from t_docfile where docFileType=#{docFileType} and valiable='Y' </select> <update id="updateInvalidDocFile" parameterType="String" > update t_docfile set valiable='N' where docFileId=#{docFileId} </update> <select id="getDocFile" parameterType="String" resultType="DocFile"> select * from t_docfile where docFileId=#{docFileId} </select>
但啟動後就莫名其妙報找不到這個DocFile類。且提示的路徑中war包後面多了一個感嘆號。
後來發現是自己在mapper文件的類引用上大意了,沒有把完整的包路徑加上
<select id="getDocFile" parameterType="String" resultType="DocFile"> select * from t_docfile where docFileId=#{docFileId} </select>
改為
<select id="getDocFile" parameterType="String" resultType="com.bbc_kit.operation.entities.DocFile"> select * from t_docfile where docFileId=#{docFileId} </select>
再打包上傳重啟就正常了。本地環境不報錯是環境內部的一些配置混亂了,沒有顯現出來。