首页 \ 问答 \ mybatis配置问题(mybatis config problem)

mybatis配置问题(mybatis config problem)

我是MyBatis的新手。

我一直试图在我写的网络服务中配置mybatis,但还没有运气。

我已经做的是,

  1. UserInfoMapper接口
  2. 带有mapper命名空间的UserInfoMapper.xml,带有UserInfoMapper接口和一个select
  3. 带有typeAlias的mybatis-config.xml,用作UserInfoMapper.xml中的结果类型
  4. datasourceContext.xml中的oracle(我得连接)的dataSource bean
  5. org.mybatis.spring.mapper.MapperScannerConfigurer bean,basePackage指向datasourceContext.xml中的UserInfoMapper接口
  6. sqlSessionFactory bean即。 org.mybatis.spring.SqlSessionFactoryBean,包含我的dataSource和configLocation的属性
  7. userInfoMapper bean即。 在datasourceContext.xml中使用属性mapperInterface(value =“is.simnn.act.web.ngs.persistence.UserInfoMapper”)和sqlSessionFactory属性(ref =“sqlSessionFactory”)的org.mybatis.spring.mapper.MapperFactoryBean
  8. 然后在我的applicationContext.xml中我有以下内容,

<import resource="classpath:META-INF/wsContext.xml" />
<import resource="classpath:META-INF/db/datasourceContext.xml" />

在我的测试用例中,当我调用jaxws:endpoint时,我一直得到NullPointerException,它引导我进入UserInfoMapper接口。

对我的配置可能出错的任何想法或提示?

谢谢,Gunnlaugur


I'm new to MyBatis.

Ive been trying to configure mybatis in a webservice I'm writing but with no luck yet.

What I've done already is,

  1. UserInfoMapper interface
  2. UserInfoMapper.xml with mapper namespace with my UserInfoMapper interface and a select
  3. mybatis-config.xml with typeAlias to use as result type in UserInfoMapper.xml
  4. dataSource bean for oracle (I get connected) in datasourceContext.xml
  5. org.mybatis.spring.mapper.MapperScannerConfigurer bean with basePackage pointing to my UserInfoMapper interface in datasourceContext.xml
  6. sqlSessionFactory bean ie. org.mybatis.spring.SqlSessionFactoryBean with property for my dataSource and configLocation
  7. userInfoMapper bean ie. org.mybatis.spring.mapper.MapperFactoryBean with property mapperInterface (value="is.simnn.act.web.ngs.persistence.UserInfoMapper") and sqlSessionFactory property (ref="sqlSessionFactory") in datasourceContext.xml
  8. then in my applicationContext.xml I have following,

<import resource="classpath:META-INF/wsContext.xml" />
<import resource="classpath:META-INF/db/datasourceContext.xml" />

In my test case I keep getting NullPointerException when I call jaxws:endpoint and it leads me to my UserInfoMapper interface.

Any idea or hints to what might be wrong with my config?

Thanks, Gunnlaugur


原文:https://stackoverflow.com/questions/5991100
更新时间:2022-01-27 13:01

最满意答案

更新public / index.php

<?php
define('YII_ENABLE_ERROR_HANDLER', false);
define('YII_ENABLE_EXCEPTION_HANDLER', false);

// Turn off all error reporting
// error_reporting(0);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

Update public/index.php

<?php
define('YII_ENABLE_ERROR_HANDLER', false);
define('YII_ENABLE_EXCEPTION_HANDLER', false);

// Turn off all error reporting
// error_reporting(0);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

相关问答

更多
  • 'dataprovider'=>$dataprovider 你必须改变 'dataProvider'=>$dataprovider 因为变量名称区分大小写 'dataprovider'=>$dataprovider you have to change to 'dataProvider'=>$dataprovider because the variable name is case-sensitive
  • CakePHP的功能确实如此 $this->header(array( 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT", 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' )); 所以也许你可以用: header("E ...
  • 是的,这是可能的,甚至在官方文档中提到过 。 一种方法是通过应用程序配置: return [ // ... 'components' => [ 'assetManager' => [ 'bundles' => [ 'mdm\admin\AdminAsset' => false, ], ], ], ]; 另一种方式 - 在运行时通过组件: \Yii::$app->asset ...
  • 尝试将分页(在您的控制器中)设置为false,如下所示: $dataProvider = new ActiveDataProvider([ 'query' => SomeModelClass::find(), 'pagination' => false, ]); Try setting pagination (in your controller) to false, like this: $dataProvider = new ActiveDataProvider([ ...
  • 关闭验证规则很简单: $model->save(false); 这不会做任何验证,只会尝试并保存模型(可能仍会在数据库端失败)。 但是如果你想运行一些验证,你可能想在这里查看场景 。 它们允许您指定一组不同的规则,具体取决于您使用哪种方案初始化模型。 这样,您只能打开/关闭整套验证规则。 $model = new Thingy(); $model->save(); // All default validation rules $model = new Thingy('draft'); $model-> ...
  • 您可以在错误屏幕上轻松看到您向我们显示发送到名为refresh()的方法的$anchor是一个数组,并且您正在尝试将其连接,就像它是一个字符串一样。 这就对了。 由于该屏幕上的文档说$anchor预计是该方法中的字符串,因此唯一的原因是您发送的数据不正确。 You can easily see on the error screen you have shown us that $anchor being sent to the method named refresh() is an array, and ...