1
我是MyBatis的新手。mybatis配置问题
我一直在尝试在web服务中配置mybatis我正在写,但没有运气。
我所做的已经是,
- UserInfoMapper接口
- UserInfoMapper.xml与映射器的命名空间与我UserInfoMapper接口和选择
- 的MyBatis-config.xml中与typeAlias作为结果使用在UserInfoMapper.xml中输入
- datasourceContext.xml中的oracle数据源bean(我已连接)
- org.mybatis.spring.mapper.MapperScannerConfigurer bean with basePackag e指向我datasourceContext.xml中的UserInfoMapper接口
- sqlSessionFactory bean ie。 org.mybatis.spring.SqlSessionFactoryBean具有我的dataSource和configLocation属性
- userInfoMapper bean即。 org.mybatis.spring.mapper.MapperFactoryBean在datasourceContext.xml中具有属性mapperInterface(value =“is.simnn.act.web.ngs.persistence.UserInfoMapper”)和sqlSessionFactory属性(ref =“sqlSessionFactory”)
- 然后我的applicationContext.xml我有以下,
<import resource="classpath:META-INF/wsContext.xml" />
<import resource="classpath:META-INF/db/datasourceContext.xml" />
在我的测试情况下,我不断收到NullPointerException异常,当我打电话JAXWS:端点,它使我对我UserInfoMapper接口。
任何想法或提示什么可能是我的配置错?
感谢, Gunnlaugur
嗨,马克,这里是我的xml <映射器命名空间= “is.simnn.act.web.ngs.mappers.UserInfoMapper”> \t <选择的id = “getUserInfoBySnb” 参数类型= “字符串” 与resultType = “用户信息” > \t \t SELECT \t \t \t port.snb, \t \t \t port.timestamp, \t \t \t port.user_type, \t \t \t port.real_exch, \t \t \t port.act_exch, \t \t \t port.dev_type, \t \t \t端口。RC \t \t FROM \t \t \t端口 \t \t WHERE \t \t \t port.snb =#{} SNB \t 这是我的接口公共接口UserInfoMapper { \t公众的UserInfo getUserInfoBySnb(字符串SNB) ; \t public UserInfo getAllUserInfoBySnb(String snb); \t public UserInfo getUserInfoByImsi(String imsi); } – Gunnlaugur 2011-05-17 08:30:28
好吧,我设法摆脱了NullPointerException,但现在我得到了java.lang.IllegalArgumentException:Mapped Statements集合不包含is.simnn.act.web.ngs.mappers.UserInfoMapper.getUserInfoBySnb的值。我正在使用mybatis-spring-1.0.1-SNAPSHOT和mybatis-3.0.5-SNAPSHOT。 – Gunnlaugur 2011-05-17 08:38:58
XML中的resultType'userInfo'是一个typeAlias?如果不是,则需要用完整的包名称命名结果类型类:com.your.package.UserInfo。您也可以尝试将注释'@Param(“snb”)'添加到您的UserInfoMapper接口,例如'public UserInfo getUserInfoBySnb(@Param(“snb”)String snb)' – Mark 2011-05-18 14:17:14