There is no statement named saveprimaryUBDin this SqlMap.

疯狂de攻城狮 2014-07-21 10:27:49
ApplicationContext ac = new ClassPathXmlApplicationContext("config/spring-mvc.xml");
SqlMapClientTemplate smct = (SqlMapClientTemplate) ac.getBean("sqlMapClientTemplate");
public class BehaviorDaoImpl{
public void saveUBD(){
smct.insert("saveprimaryUBD",subd);
}
}


spring-mvc配置文件如下:
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-autowire="byName"
>
<!-- spring注解 -->
<context:annotation-config />
<!-- <context:component-scan base-package="com.founder.ec" /> -->

<!-- Ibatis SqlMap -->
<!-- 连接对象 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" >
<property name="configLocation" value="classpath:config/sqlMap.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 连接对象模板 -->
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate" >
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
<!-- 数据源 -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" >
<property name="driver">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="driverUrl">
<value>jdbc:mysql://localhost:3306/user_behavior_data</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>zxc123</value>
</property>

</bean>

</beans>


sqlMap.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 指定映射器路径 -->
<mappers>
<mapper resource="sql/ubd.xml" />
</mappers>
</configuration>


ubd.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
<mapper namespace="com.founder.ec.dao.impl.BehaviorDaoImpl">

<insert id="saveprimaryUBD" parameterType="com.founder.ec.entity.PrimaryUBD">
insert into user_behavior_data.primary_UBD
(
sessionId,
UUID,
ip,
memberId,
firstPage,
initTime,
isNewVisit
)
values
(
#{sessionId},
#{uuid},
#{ip},
#{memberId},
#{firstPage},
#{initTime},
#{isNewVisit}
)
</insert>
<mapper>


项目结构如下:

各路神仙,帮我找找,这是什么原因?
...全文
157 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
疯狂de攻城狮 2014-07-21
  • 打赏
  • 举报
回复
疯狂de攻城狮 2014-07-21
  • 打赏
  • 举报
回复
2楼方法,行不通,已经试过了。
suciver 2014-07-21
  • 打赏
  • 举报
回复
2楼已经给出答案了,把你ibatis的xml中的namespace加上
疯狂de攻城狮 2014-07-21
  • 打赏
  • 举报
回复
二楼方法走不通,我是单机跑的,不知道会不会有关系?
疯狂de攻城狮 2014-07-21
  • 打赏
  • 举报
回复
请问,楼上类路径指的是什么路径
wqc5461 2014-07-21
  • 打赏
  • 举报
回复

smct.insert("com.founder.ec.dao.impl.BehaviorDaoImpl.saveprimaryUBD",subd);
shixitong 2014-07-21
  • 打赏
  • 举报
回复
看配置好像没有问题(还是眼拙没看出来),sqlmapping文件在类路径里了吧?
疯狂de攻城狮 2014-07-21
  • 打赏
  • 举报
回复
问题解决了,与其说解决了问题,不如说避开了问题,转换一种思路,我把sqlMap.xml和ubd.xml中的mapper标签改为了sqlMap标签,这样问题就迎刃而解了。 最后,还是谢谢各位热心的回答!

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧