mybatis MapperScannerConfigurer

classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|

mybatis MapperScannerConfigurer

erha
Hi,

I have decided to choose mybatis and spring in my current project. I
have read the document mybatis-spring-1.0.0-reference.pdf and read a
lot from this forum.

Currently I am encountering problem java.lang.NullPointerException
when I am calling the mapper. I have tried to enable the logging, and
I could see the log created by org.mybatis.spring. But when the error
occur, I didn't see any error.

This exception happen exactly when I called the method that I declare
in the mapper.

Can anybody point out the possible problem for this exception?
I have been searching high and low in the last 2 days and I could not
found any solution...

Thanks in advance...
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Eduardo Macarron

erha, please post a log or a stacktrace, so we can help you.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

erha
Hi Eduardo,

Below is the log and stack trace. The class name MenuInfoMapper is my
mapper.

INFO  02-27 20:25:01 Root WebApplicationContext: initialization
started  (ContextLoader.java:187)
INFO  02-27 20:25:01 Refreshing Root WebApplicationContext: startup
date [Sun Feb 27 20:25:01 SGT 2011]; root of context hierarchy
(AbstractApplicationContext.java:456)
INFO  02-27 20:25:01 Loading XML bean definitions from ServletContext
resource [/WEB-INF/applicationContext.xml]
(XmlBeanDefinitionReader.java:315)
DEBUG 02-27 20:25:01 Using JAXP provider
[com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
(DefaultDocumentLoader.java:72)
DEBUG 02-27 20:25:01 Found beans DTD [http://www.springframework.org/
dtd/spring-beans.dtd] in classpath: spring-beans.dtd
(BeansDtdResolver.java:73)
DEBUG 02-27 20:25:01 Loading bean definitions
(DefaultBeanDefinitionDocumentReader.java:87)
DEBUG 02-27 20:25:01 Loaded 0 bean definitions from location pattern [/
WEB-INF/applicationContext.xml]  (AbstractBeanDefinitionReader.java:
185)
INFO  02-27 20:25:01 Loading XML bean definitions from ServletContext
resource [/WEB-INF/myBatis.xml]  (XmlBeanDefinitionReader.java:315)
DEBUG 02-27 20:25:01 Using JAXP provider
[com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
(DefaultDocumentLoader.java:72)
DEBUG 02-27 20:25:01 Loading schema mappings from [META-INF/
spring.schemas]  (PluggableSchemaResolver.java:140)
DEBUG 02-27 20:25:01 Loaded schema mappings: {http://
www.springframework.org/schema/oxm/spring-oxm-3.0.xsd=org/springframework/oxm/config/spring-oxm-3.0.xsd,
http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd,
http://www.zkoss.org/2008/zkspring/core/zkspring-core.xsd=metainfo/xml/zkspring-core.xsd,
http://www.springframework.org/schema/jms/spring-jms-3.0.xsd=org/springframework/jms/config/spring-jms-3.0.xsd,
http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd,
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd,
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd,
http://www.springframework.org/schema/oxm/spring-oxm.xsd=org/springframework/oxm/config/spring-oxm-3.0.xsd,
http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd,
http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd,
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd,
http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.0.xsd,
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd,
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd=org/springframework/web/servlet/config/spring-mvc-3.0.xsd,
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd,
http://www.zkoss.org/2008/zkspring/security/zkspring-security.xsd=metainfo/xml/zkspring-security.xsd,
http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd,
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd,
http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd,
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd,
http://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd,
http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd,
http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd,
http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd,
http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd,
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd,
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd,
http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd,
http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.0.xsd,
http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd,
http://www.springframework.org/schema/jms/spring-jms-2.5.xsd=org/springframework/jms/config/spring-jms-2.5.xsd,
http://www.springframework.org/schema/jms/spring-jms.xsd=org/springframework/jms/config/spring-jms-3.0.xsd,
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd,
http://www.springframework.org/schema/mvc/spring-mvc.xsd=org/springframework/web/servlet/config/spring-mvc-3.0.xsd,
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd,
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd,
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd,
http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd,
http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd,
http://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd,
http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd,
http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd,
http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd,
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd}
(PluggableSchemaResolver.java:146)
DEBUG 02-27 20:25:01 Found XML schema [http://www.springframework.org/
schema/beans/spring-beans-3.0.xsd] in classpath: org/springframework/
beans/factory/xml/spring-beans-3.0.xsd  (PluggableSchemaResolver.java:
118)
DEBUG 02-27 20:25:01 Found XML schema [http://www.springframework.org/
schema/context/spring-context-3.0.xsd] in classpath: org/
springframework/context/config/spring-context-3.0.xsd
(PluggableSchemaResolver.java:118)
DEBUG 02-27 20:25:01 Found XML schema [http://www.springframework.org/
schema/tool/spring-tool-3.0.xsd] in classpath: org/springframework/
beans/factory/xml/spring-tool-3.0.xsd  (PluggableSchemaResolver.java:
118)
DEBUG 02-27 20:25:01 Found XML schema [http://www.springframework.org/
schema/tx/spring-tx-3.0.xsd] in classpath: org/springframework/
transaction/config/spring-tx-3.0.xsd  (PluggableSchemaResolver.java:
118)
DEBUG 02-27 20:25:01 Loading bean definitions
(DefaultBeanDefinitionDocumentReader.java:87)
DEBUG 02-27 20:25:01 Loaded NamespaceHandler mappings: {http://
www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler,
http://www.springframework.org/schema/mvc=org.springframework.web.servlet.config.MvcNamespaceHandler,
http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler,
http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler,
http://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler,
http://www.springframework.org/schema/oxm=org.springframework.oxm.config.OxmNamespaceHandler,
http://www.springframework.org/schema/jdbc=org.springframework.jdbc.config.JdbcNamespaceHandler,
http://www.zkoss.org/2008/zkspring/core=org.zkoss.spring.config.ZkSpringNamespaceHandler,
http://www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler,
http://www.zkoss.org/2008/zkspring/security=org.zkoss.spring.config.ZkSpringSecurityNamespaceHandler,
http://www.springframework.org/schema/jms=org.springframework.jms.config.JmsNamespaceHandler,
http://www.springframework.org/schema/task=org.springframework.scheduling.config.TaskNamespaceHandler,
http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler,
http://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler}
(DefaultNamespaceHandlerResolver.java:156)
DEBUG 02-27 20:25:01 Looking for matching resources in directory tree
[Y:\Projects\Alexander\Workspace\.metadata\.plugins
\org.eclipse.wst.server.core\tmp0\wtpwebapps\Alexander\WEB-INF\classes
\alexander\service]  (PathMatchingResourcePatternResolver.java:552)
DEBUG 02-27 20:25:01 Searching directory [Y:\Projects\Alexander
\Workspace\.metadata\.plugins\org.eclipse.wst.server.core
\tmp0\wtpwebapps\Alexander\WEB-INF\classes\alexander\service] for
files matching pattern [Y:/Projects/Alexander/
Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/
wtpwebapps/Alexander/WEB-INF/classes/alexander/service/**/*.class]
(PathMatchingResourcePatternResolver.java:614)
DEBUG 02-27 20:25:01 Resolved location pattern [classpath*:alexander/
service/**/*.class] to resources [file [Y:\Projects\Alexander\Workspace
\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
\Alexander\WEB-INF\classes\alexander\service\MenuInfoService.class]]
(PathMatchingResourcePatternResolver.java:353)
DEBUG 02-27 20:25:01 Identified candidate component class: file [Y:
\Projects\Alexander\Workspace\.metadata\.plugins
\org.eclipse.wst.server.core\tmp0\wtpwebapps\Alexander\WEB-INF\classes
\alexander\service\MenuInfoService.class]
(ClassPathScanningCandidateComponentProvider.java:220)
DEBUG 02-27 20:25:01 Neither XML 'id' nor 'name' specified - using
generated bean name
[org.mybatis.spring.mapper.MapperScannerConfigurer#0]
(BeanDefinitionParserDelegate.java:417)
DEBUG 02-27 20:25:01 Loaded 13 bean definitions from location pattern
[/WEB-INF/myBatis.xml]  (AbstractBeanDefinitionReader.java:185)
DEBUG 02-27 20:25:01 Bean factory for Root WebApplicationContext:
org.springframework.beans.factory.support.DefaultListableBeanFactory@149a794:
defining beans
[dataSource,menuInfoService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,sqlSessionFactory,transactionManager,org.mybatis.spring.mapper.MapperScannerConfigurer#0];
root of factory hierarchy  (AbstractApplicationContext.java:470)
DEBUG 02-27 20:25:01 Creating shared instance of singleton bean
'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:01 Creating instance of bean
'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:01 Eagerly caching bean
'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
to allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:01 Finished creating instance of bean
'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:01 Creating shared instance of singleton bean
'org.mybatis.spring.mapper.MapperScannerConfigurer#0'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:01 Creating instance of bean
'org.mybatis.spring.mapper.MapperScannerConfigurer#0'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:01 Eagerly caching bean
'org.mybatis.spring.mapper.MapperScannerConfigurer#0' to allow for
resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:01 Creating shared instance of singleton bean
'sqlSessionFactory'  (DefaultSingletonBeanRegistry.java:214)
DEBUG 02-27 20:25:01 Creating instance of bean
'sqlSessionFactory'  (AbstractAutowireCapableBeanFactory.java:430)
DEBUG 02-27 20:25:01 Logging initialized using
'org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl'
adapter.  (JakartaCommonsLoggingImpl.java:27)
DEBUG 02-27 20:25:01 Eagerly caching bean 'sqlSessionFactory' to allow
for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:01 Creating shared instance of singleton bean
'dataSource'  (DefaultSingletonBeanRegistry.java:214)
DEBUG 02-27 20:25:01 Creating instance of bean
'dataSource'  (AbstractAutowireCapableBeanFactory.java:430)
DEBUG 02-27 20:25:01 Eagerly caching bean 'dataSource' to allow for
resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:01 Invoking afterPropertiesSet() on bean with name
'dataSource'  (AbstractAutowireCapableBeanFactory.java:1461)
DEBUG 02-27 20:25:01 Looking up JNDI object with name [java:comp/env/
jdbc/current]  (JndiTemplate.java:150)
DEBUG 02-27 20:25:01 Located object with JNDI name [java:comp/env/jdbc/
current]  (JndiLocatorSupport.java:111)
DEBUG 02-27 20:25:01 Finished creating instance of bean
'dataSource'  (AbstractAutowireCapableBeanFactory.java:458)
DEBUG 02-27 20:25:01 Invoking afterPropertiesSet() on bean with name
'sqlSessionFactory'  (AbstractAutowireCapableBeanFactory.java:1461)
DEBUG 02-27 20:25:02 Parsed configuration file: 'class path resource
[myBatisConfig.xml]'  (JakartaCommonsLoggingImpl.java:27)
DEBUG 02-27 20:25:02 Property 'mapperLocations' was not specified,
only MyBatis mapper files specified in the config xml were loaded
(JakartaCommonsLoggingImpl.java:27)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'sqlSessionFactory'  (AbstractAutowireCapableBeanFactory.java:458)
DEBUG 02-27 20:25:02 Invoking afterPropertiesSet() on bean with name
'org.mybatis.spring.mapper.MapperScannerConfigurer#0'  (AbstractAutowireCapableBeanFactory.java:
1461)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.mybatis.spring.mapper.MapperScannerConfigurer#0'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Looking for matching resources in directory tree
[Y:\Projects\Alexander\Workspace\.metadata\.plugins
\org.eclipse.wst.server.core\tmp0\wtpwebapps\Alexander\WEB-INF\classes
\alexander\mapper]  (PathMatchingResourcePatternResolver.java:552)
DEBUG 02-27 20:25:02 Searching directory [Y:\Projects\Alexander
\Workspace\.metadata\.plugins\org.eclipse.wst.server.core
\tmp0\wtpwebapps\Alexander\WEB-INF\classes\alexander\mapper] for files
matching pattern [Y:/Projects/Alexander/Workspace/.metadata/.plugins/
org.eclipse.wst.server.core/tmp0/wtpwebapps/Alexander/WEB-INF/classes/
alexander/mapper/**/*.class]
(PathMatchingResourcePatternResolver.java:614)
DEBUG 02-27 20:25:02 Resolved location pattern [classpath*:alexander/
mapper/**/*.class] to resources [file [Y:\Projects\Alexander\Workspace
\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
\Alexander\WEB-INF\classes\alexander\mapper\MenuInfoMapper.class]]
(PathMatchingResourcePatternResolver.java:353)
DEBUG 02-27 20:25:02 Identified candidate component class: file [Y:
\Projects\Alexander\Workspace\.metadata\.plugins
\org.eclipse.wst.server.core\tmp0\wtpwebapps\Alexander\WEB-INF\classes
\alexander\mapper\MenuInfoMapper.class]
(ClassPathScanningCandidateComponentProvider.java:220)
DEBUG 02-27 20:25:02 Creating MapperFactoryBean with name
'menuInfoMapper' and 'alexander.mapper.MenuInfoMapper'
mapperInterface  (MapperScannerConfigurer.java:215)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:02 Creating instance of bean
'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:02 Eagerly caching bean
'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
to allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'org.springframework.context.annotation.internalRequiredAnnotationProcessor'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:02 Creating instance of bean
'org.springframework.context.annotation.internalRequiredAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:02 Eagerly caching bean
'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
to allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.springframework.context.annotation.internalRequiredAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'org.springframework.context.annotation.internalCommonAnnotationProcessor'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:02 Creating instance of bean
'org.springframework.context.annotation.internalCommonAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:02 Eagerly caching bean
'org.springframework.context.annotation.internalCommonAnnotationProcessor'
to allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.springframework.context.annotation.internalCommonAnnotationProcessor'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'org.springframework.aop.config.internalAutoProxyCreator'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:02 Creating instance of bean
'org.springframework.aop.config.internalAutoProxyCreator'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:02 Eagerly caching bean
'org.springframework.aop.config.internalAutoProxyCreator' to allow for
resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.springframework.aop.config.internalAutoProxyCreator'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Unable to locate MessageSource with name
'messageSource': using default
[org.springframework.context.support.DelegatingMessageSource@1148603]
(AbstractApplicationContext.java:776)
DEBUG 02-27 20:25:02 Unable to locate ApplicationEventMulticaster with
name 'applicationEventMulticaster': using default
[org.springframework.context.event.SimpleApplicationEventMulticaster@cb42cf]
(AbstractApplicationContext.java:800)
DEBUG 02-27 20:25:02 Unable to locate ThemeSource with name
'themeSource': using default
[org.springframework.ui.context.support.ResourceBundleThemeSource@37d490]
(UiApplicationContextUtils.java:85)
INFO  02-27 20:25:02 Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@149a794:
defining beans
[dataSource,menuInfoService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,sqlSessionFactory,transactionManager,org.mybatis.spring.mapper.MapperScannerConfigurer#0,menuInfoMapper];
root of factory hierarchy  (DefaultListableBeanFactory.java:555)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'dataSource'  (AbstractBeanFactory.java:242)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'menuInfoService'  (DefaultSingletonBeanRegistry.java:214)
DEBUG 02-27 20:25:02 Creating instance of bean
'menuInfoService'  (AbstractAutowireCapableBeanFactory.java:430)
DEBUG 02-27 20:25:02 Found injected element on class
[alexander.service.MenuInfoService]: AutowiredFieldElement for private
alexander.mapper.MenuInfoMapper
alexander.service.MenuInfoService.menuInfoMapper
(InjectionMetadata.java:59)
DEBUG 02-27 20:25:02 Eagerly caching bean 'menuInfoService' to allow
for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Processing injected method of bean
'menuInfoService': AutowiredFieldElement for private
alexander.mapper.MenuInfoMapper
alexander.service.MenuInfoService.menuInfoMapper
(InjectionMetadata.java:82)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'menuInfoMapper'  (DefaultSingletonBeanRegistry.java:214)
DEBUG 02-27 20:25:02 Creating instance of bean
'menuInfoMapper'  (AbstractAutowireCapableBeanFactory.java:430)
DEBUG 02-27 20:25:02 Found injected element on class
[org.mybatis.spring.mapper.MapperFactoryBean]: AutowiredMethodElement
for public void
org.mybatis.spring.mapper.MapperFactoryBean.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
(InjectionMetadata.java:59)
DEBUG 02-27 20:25:02 Found injected element on class
[org.mybatis.spring.mapper.MapperFactoryBean]: AutowiredMethodElement
for public void
org.mybatis.spring.mapper.MapperFactoryBean.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
(InjectionMetadata.java:59)
DEBUG 02-27 20:25:02 Eagerly caching bean 'menuInfoMapper' to allow
for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Processing injected method of bean
'menuInfoMapper': AutowiredMethodElement for public void
org.mybatis.spring.mapper.MapperFactoryBean.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
(InjectionMetadata.java:82)
DEBUG 02-27 20:25:02 Processing injected method of bean
'menuInfoMapper': AutowiredMethodElement for public void
org.mybatis.spring.mapper.MapperFactoryBean.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
(InjectionMetadata.java:82)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:02 Creating instance of bean
'org.springframework.transaction.config.internalTransactionAdvisor'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:02 Eagerly caching bean
'org.springframework.transaction.config.internalTransactionAdvisor' to
allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:02 Creating instance of bean
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:02 Eagerly caching bean
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'
to allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.springframework.transaction.config.internalTransactionAdvisor'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Returning eagerly cached instance of singleton
bean 'menuInfoMapper' that is not fully initialized yet - a
consequence of a circular reference  (AbstractBeanFactory.java:238)
DEBUG 02-27 20:25:02 Invoking afterPropertiesSet() on bean with name
'menuInfoMapper'  (AbstractAutowireCapableBeanFactory.java:1461)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'menuInfoMapper'  (AbstractAutowireCapableBeanFactory.java:458)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'menuInfoMapper'  (AbstractBeanFactory.java:242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Autowiring by type from bean name
'menuInfoService' to bean named
'menuInfoMapper'  (AutowiredAnnotationBeanPostProcessor.java:420)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'menuInfoService'  (AbstractAutowireCapableBeanFactory.java:458)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.context.annotation.internalRequiredAnnotationProcessor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.context.annotation.internalCommonAnnotationProcessor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.aop.config.internalAutoProxyCreator'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'org.springframework.transaction.interceptor.TransactionInterceptor#0'  (DefaultSingletonBeanRegistry.java:
214)
DEBUG 02-27 20:25:02 Creating instance of bean
'org.springframework.transaction.interceptor.TransactionInterceptor#0'  (AbstractAutowireCapableBeanFactory.java:
430)
DEBUG 02-27 20:25:02 Eagerly caching bean
'org.springframework.transaction.interceptor.TransactionInterceptor#0'
to allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Invoking afterPropertiesSet() on bean with name
'org.springframework.transaction.interceptor.TransactionInterceptor#0'  (AbstractAutowireCapableBeanFactory.java:
1461)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'org.springframework.transaction.interceptor.TransactionInterceptor#0'  (AbstractAutowireCapableBeanFactory.java:
458)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'sqlSessionFactory'  (AbstractBeanFactory.java:242)
DEBUG 02-27 20:25:02 Creating shared instance of singleton bean
'transactionManager'  (DefaultSingletonBeanRegistry.java:214)
DEBUG 02-27 20:25:02 Creating instance of bean
'transactionManager'  (AbstractAutowireCapableBeanFactory.java:430)
DEBUG 02-27 20:25:02 Eagerly caching bean 'transactionManager' to
allow for resolving potential circular references
(AbstractAutowireCapableBeanFactory.java:504)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'dataSource'  (AbstractBeanFactory.java:242)
DEBUG 02-27 20:25:02 Invoking afterPropertiesSet() on bean with name
'transactionManager'  (AbstractAutowireCapableBeanFactory.java:1461)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Finished creating instance of bean
'transactionManager'  (AbstractAutowireCapableBeanFactory.java:458)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'org.mybatis.spring.mapper.MapperScannerConfigurer#0'  (AbstractBeanFactory.java:
242)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'menuInfoMapper'  (AbstractBeanFactory.java:242)
DEBUG 02-27 20:25:02 Unable to locate LifecycleProcessor with name
'lifecycleProcessor': using default
[org.springframework.context.support.DefaultLifecycleProcessor@8a52b6]
(AbstractApplicationContext.java:827)
DEBUG 02-27 20:25:02 Returning cached instance of singleton bean
'lifecycleProcessor'  (AbstractBeanFactory.java:242)
DEBUG 02-27 20:25:02 Published root WebApplicationContext as
ServletContext attribute with name
[org.springframework.web.context.WebApplicationContext.ROOT]
(ContextLoader.java:209)
INFO  02-27 20:25:02 Root WebApplicationContext: initialization
completed in 1166 ms  (ContextLoader.java:214)

The stack trace:

java.lang.NullPointerException
        at alexander.service.MenuInfoService.getDisplay(MenuInfoService.java:
41)
        at
alexander.composer.MainMenuComposer.doAfterCompose(MainMenuComposer.java:
35)
        at
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:
739)
        at
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:
685)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:
629)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:
596)
        at
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:
730)
        at
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:
685)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:
629)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:
596)
        at
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:
730)
        at
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:
685)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:
629)
        at
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:
661)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:
629)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:
596)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:
382)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:
305)
        at
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:
225)
        at
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:
146)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
306)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
210)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
240)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
161)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
164)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
100)
        at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
541)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
118)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
383)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
243)
        at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:166)
        at org.apache.tomcat.util.net.JIoEndpoint
$SocketProcessor.run(JIoEndpoint.java:288)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Eduardo Macarron
But the NPE is fired inside your service class. I suppose this is
because the mapper "'alexander.mapper.MenuInfoMapper" has not been
into your service bean?

Maybe you coud post your spring config and your MenuInfoService?
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

erha
Hi Eduardo,

Below is the MenuInfoService code:

package alexander.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import alexander.data.MenuInfo;
import alexander.mapper.MenuInfoMapper;

@Service
public class MenuInfoService
{
        @Autowired
        private MenuInfoMapper menuInfoMapper;

        public String getDisplay()
        {
                return menuInfoMapper.getDisplay();
        }
}

And below is the spring configuration:

<beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:aop="http://www.springframework.org/schema/aop"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xmlns:jdbc="http://www.springframework.org/schema/jdbc"
     xmlns:context="http://www.springframework.org/schema/context"
     xsi:schemaLocation="
     http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-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/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
     http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
     http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="java:comp/env/jdbc/current"/>
    </bean>

    <context:component-scan base-package="alexander.service" />
    <context:annotation-config />
    <tx:annotation-driven />

    <bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation"
value="classpath:myBatisConfig.xml" />
    </bean>

    <bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="alexander.mapper" />
        <property name="sqlSessionFactory" ref="sqlSessionFactory"/>
    </bean>
</beans>

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Eduardo Macarron
Seems ok.... could you try adding a setter to your field and moving
the @Autowire to it?

Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

erha
Hi Eduardo,

What did you mean by adding a setter to the field?

On Feb 28, 7:23 pm, Eduardo <[hidden email]> wrote:
> Seems ok.... could you try adding a setter to your field and moving
> the @Autowire to it?
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

陈抒
In reply to this post by Eduardo Macarron
I am using @Autowired in my Java codes,I don't like XML configuration when using Spring because it's hard to review codes.

陈抒
Best regards
http://blog.csdn.net/sheismylife


On Mon, Feb 28, 2011 at 7:23 PM, Eduardo <[hidden email]> wrote:
Seems ok.... could you try adding a setter to your field and moving
the @Autowire to it?


Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

陈抒
I just read Spring3 document,maybe Eduardo means add a setter and user @Required like so:
@Service
public class MenuInfoService
{

       private MenuInfoMapper menuInfoMapper;

       @Required
       public setMenuInfoMapper(MenuInfoMapper newMapper){
          menuInfoMapper=newMapper;
       }

       public String getDisplay()
       {
               return menuInfoMapper.getDisplay();
       }
}

陈抒
Best regards
http://blog.csdn.net/sheismylife


On Mon, Feb 28, 2011 at 7:57 PM, 陈抒 <[hidden email]> wrote:
I am using @Autowired in my Java codes,I don't like XML configuration when using Spring because it's hard to review codes.

陈抒
Best regards
http://blog.csdn.net/sheismylife



On Mon, Feb 28, 2011 at 7:23 PM, Eduardo <[hidden email]> wrote:
Seems ok.... could you try adding a setter to your field and moving
the @Autowire to it?



Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Eduardo Macarron
In reply to this post by erha
:)

No idea. Just to try given that everything looks fine.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Paulo Soares
Please, change in your spring config, this:
<context:component-scan base-package="alexander.service" />

To:
<context:component-scan base-package="alexander" />

If not work, please, send your Mapper class.


Paulo Soares

Em 28/02/2011, às 09:47, Eduardo <[hidden email]> escreveu:

:)

No idea. Just to try given that everything looks fine.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

erha
In reply to this post by Eduardo Macarron
If I put the setter function as suggested, I got the following
exception:

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'menuInfoService' defined in file [Y:\Projects
\Alexander\Workspace\.metadata\.plugins\org.eclipse.wst.server.core
\tmp0\wtpwebapps\Alexander\WEB-INF\classes\alexander\service
\MenuInfoService.class]: Initialization of bean failed; nested
exception is
org.springframework.beans.factory.BeanInitializationException:
Property 'menuInfoMapper' is required for bean 'menuInfoService'
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
527)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
456)
        at org.springframework.beans.factory.support.AbstractBeanFactory
$1.getObject(AbstractBeanFactory.java:291)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
222)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
288)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
190)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
580)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
895)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
425)
        at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:
276)
        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
197)
        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
47)
        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
4600)
        at org.apache.catalina.core.StandardContext
$1.call(StandardContext.java:5097)
        at org.apache.catalina.core.StandardContext
$1.call(StandardContext.java:5092)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by:
org.springframework.beans.factory.BeanInitializationException:
Property 'menuInfoMapper' is required for bean 'menuInfoService'
        at
org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor.postProcessPropertyValues(RequiredAnnotationBeanPostProcessor.java:
149)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:
1074)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
517)
        ... 19 more

Any more idea what could be wrong?

On Feb 28, 8:47 pm, Eduardo <[hidden email]> wrote:
> :)
>
> No idea. Just to try given that everything looks fine.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Simone Tripodi-2
did you try the Paulo's suggestion as well?
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Mon, Feb 28, 2011 at 3:28 PM, erha <[hidden email]> wrote:

> If I put the setter function as suggested, I got the following
> exception:
>
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'menuInfoService' defined in file [Y:\Projects
> \Alexander\Workspace\.metadata\.plugins\org.eclipse.wst.server.core
> \tmp0\wtpwebapps\Alexander\WEB-INF\classes\alexander\service
> \MenuInfoService.class]: Initialization of bean failed; nested
> exception is
> org.springframework.beans.factory.BeanInitializationException:
> Property 'menuInfoMapper' is required for bean 'menuInfoService'
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
> 527)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
> 456)
>        at org.springframework.beans.factory.support.AbstractBeanFactory
> $1.getObject(AbstractBeanFactory.java:291)
>        at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
> 222)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
> 288)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
> 190)
>        at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
> 580)
>        at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
> 895)
>        at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
> 425)
>        at
> org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:
> 276)
>        at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
> 197)
>        at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
> 47)
>        at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
> 4600)
>        at org.apache.catalina.core.StandardContext
> $1.call(StandardContext.java:5097)
>        at org.apache.catalina.core.StandardContext
> $1.call(StandardContext.java:5092)
>        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
>        at java.util.concurrent.FutureTask.run(Unknown Source)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>        at java.lang.Thread.run(Unknown Source)
> Caused by:
> org.springframework.beans.factory.BeanInitializationException:
> Property 'menuInfoMapper' is required for bean 'menuInfoService'
>        at
> org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor.postProcessPropertyValues(RequiredAnnotationBeanPostProcessor.java:
> 149)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:
> 1074)
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
> 517)
>        ... 19 more
>
> Any more idea what could be wrong?
>
> On Feb 28, 8:47 pm, Eduardo <[hidden email]> wrote:
>> :)
>>
>> No idea. Just to try given that everything looks fine.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

erha
In reply to this post by erha
Hi Paolo,

I have tried your suggestion and it still the same,
java.lang.NullPointerException.

My Mapper class:

package alexander.mapper;

public interface MenuInfoMapper
{
        String getDisplay();
}


The xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://
mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="alexander.mapper.MenuInfoMapper">
        <select id="getDisplay" resultType="String">
                SELECT
                        DISPLAY
                FROM MENU
                WHERE ID = 1
        </select>
</mapper>
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Eduardo Macarron
How are you getting your MenuInfoService from the Spring context in
MainMenuComposer?
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

erha
Here is the code of MenuInfoComposer:

package alexander.composer;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Menubar;
import org.zkoss.zul.Menuitem;

import alexander.service.MenuInfoService;

import net.sourceforge.stripes.integration.spring.SpringBean;

@SuppressWarnings("serial")
public class MainMenuComposer extends GenericForwardComposer
{
        @SpringBean
        private MenuInfoService jMainMenuService;
        private Menubar zMenu;

        public void doAfterCompose(Component comp)
        {
                try
                {
                        super.doAfterCompose(comp);

                        Menuitem menuItem = new Menuitem(jMainMenuService.getDisplay());
                        zMenu.appendChild(menuItem);
                }
                catch (Exception e)
                {
                        e.printStackTrace();
                }
        }
}

On Feb 28, 11:06 pm, Eduardo <[hidden email]> wrote:
> How are you getting your MenuInfoService from the Spring context in
> MainMenuComposer?
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

陈抒
In reply to this post by Eduardo Macarron
If we have one example which shows how to configure spring with mybatis,that will save a lot of time for  everyone.
I ran into the same problem before,I will show how I configure it here.
My project is a JSF2(with PrimeFaces)+Spring3.0.5+MyBatis3.0.4,using Maven3.0.2,glassfish on UBuntu.
I have a login.xhtml page,also has a pagebean named Login.java in com.webt.pagebean package.

@Component
@Lazy(true)
@Scope("view")
public class Login implements Serializable{
....
  @Autowired
  private transient UserService service;
...
}

When the browser requests login.xhtml file,JSF and Spring runtime work together to create a Login object,because the UserSerivce is a @Autowired property,the Spring runtime will create a UserService object and call Login.setService method.

UserService.java is under com.webt.service package

@Service(value="com.webt.service.UserService")
@Lazy(true)
public class UserService{
...
  @Autowired
  private UserMapper userMapper;
...
}

In the same way,Sprint will try to create a UserMapper object and call UserService.setUserMapper method.UserMapper is an interface and Sprint-MyBatis library will implement it.This interfaces contains all methods corresponding the SQL templates in xml file.

UserMapper.java is under com.webt.map package
public interface UserMapper {
  
  public User getUser(User user);

  public User getUserByEmail(User user);
...
}

In my maven web project,all xml files that contain SQL templates are in /src/main/resources/map folder.
UserMapper.xml looks like so:

<mapper namespace="com.webt.mapper.UserMapper">
  <resultMap id="userResultMap" type="User">
    <id property="id" column="Id" />
    <result property="name" column="Name"/>
    <result property="passwordHashValue" column="PasswordHashValue"/>
    <result property="email" column="Email"/>
    <result property="phone" column="Phone"/>
    <result property="address" column="Address"/>
    <result property="gender" column="Sex"/>
    <result property="active" column="Active"/>
  </resultMap>

  <select id="getUser" parameterType="User" resultMap="userResultMap" >
    select Id,PasswordHashValue,Salt,Name,Email,Phone,Address,Sex,Active from User where Name = #{name} or Email = #{email}
  </select>

  <select id="getAllUsers" resultMap="userResultMap" >
    select * from User
  </select>
...
</mapper>


Another important xml file is under /src/main/resources folder
mybatisConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
<configuration>
  <typeAliases>
    <typeAlias alias="User" type="com.webt.user.User"/>
    <typeAlias alias="LoginRecord" type="com.webt.user.LoginRecord"/>
    <typeAlias alias="LoginFailedInfo" type="com.webt.user.LoginFailedInfo"/>
    <typeAlias alias="Display" type="com.webt.data.Display"/>
    <typeAlias alias="Data" type="com.webt.data.Data"/>
    <typeAlias alias="DataBlock" type="com.webt.data.DataBlock"/>
    <typeAlias alias="EmailSender" type="com.webt.email.EmailSender"/>
    <typeAlias alias="Role" type="com.webt.user.Role"/>
  </typeAliases>
  <mappers>
    <mapper resource="map/UserMapper.xml" />
    <mapper resource="map/DisplayMapper.xml" />
    <mapper resource="map/EmailSettingMapper.xml" />
  </mappers>
</configuration>


The last thing is to configure the applicationContext.xml for spring now.
It lies in src/main/webapp/WEB-INF folder.

<?xml version="1.0" encoding="UTF-8"?>
  <context:annotation-config/>
  
  <context:component-scan base-package="com.webt"/>  

  <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
    <property name="scopes">
      <map>
<entry key="view">
 <bean class="com.webt.scope.ViewScope"/>
</entry>
      </map>
    </property>
  </bean>

  <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>

  <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
    <property name="driverClass" value="com.mysql.jdbc.Driver" />
    <property name="username" value="freebird"/>
    <property name="password" value="770328"/>
    <property name="idleConnectionTestPeriod" value="60"/>
    <property name="idleMaxAge" value="240"/>
    <property name="maxConnectionsPerPartition" value="30"/>
    <property name="minConnectionsPerPartition" value="10"/>
    <property name="partitionCount" value="3"/>
    <property name="acquireIncrement" value="5"/>
    <property name="statementsCacheSize" value="100"/>
    <property name="releaseHelperThreads" value="3"/>
  </bean>
  
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
  </bean>
  
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="configLocation" value="classpath:mybatisConfig.xml"/>
  </bean>

  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.webt.mapper" />
  </bean>


</beans>

Let me know if you still have questions.Also,I suggest using BoneCP as your connection pool.

陈抒
Best regards
http://blog.csdn.net/sheismylife


On Mon, Feb 28, 2011 at 11:06 PM, Eduardo <[hidden email]> wrote:
How are you getting your MenuInfoService from the Spring context in
MainMenuComposer?

Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Simone Tripodi-2
Ni hao 陈抒
examples *are* available on MyBatis repository:

[1] simple example: http://tinyurl.com/5upkxdn
[2] JPetStore 6: http://tinyurl.com/6y6m5ln

Zai jihan,
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Mon, Feb 28, 2011 at 4:36 PM, 陈抒 <[hidden email]> wrote:

> If we have one example which shows how to configure spring with mybatis,that
> will save a lot of time for  everyone.
> I ran into the same problem before,I will show how I configure it here.
> My project is a JSF2(with PrimeFaces)+Spring3.0.5+MyBatis3.0.4,using
> Maven3.0.2,glassfish on UBuntu.
> I have a login.xhtml page,also has a pagebean named Login.java in
> com.webt.pagebean package.
> @Component
> @Lazy(true)
> @Scope("view")
> public class Login implements Serializable{
> ....
>   @Autowired
>   private transient UserService service;
> ...
> }
> When the browser requests login.xhtml file,JSF and Spring runtime work
> together to create a Login object,because the UserSerivce is a @Autowired
> property,the Spring runtime will create a UserService object and call
> Login.setService method.
> UserService.java is under com.webt.service package
> @Service(value="com.webt.service.UserService")
> @Lazy(true)
> public class UserService{
> ...
>   @Autowired
>   private UserMapper userMapper;
> ...
> }
> In the same way,Sprint will try to create a UserMapper object and call
> UserService.setUserMapper method.UserMapper is an interface and
> Sprint-MyBatis library will implement it.This interfaces contains all
> methods corresponding the SQL templates in xml file.
> UserMapper.java is under com.webt.map package
> public interface UserMapper {
>
>   public User getUser(User user);
>   public User getUserByEmail(User user);
> ...
> }
> In my maven web project,all xml files that contain SQL templates are in
> /src/main/resources/map folder.
> UserMapper.xml looks like so:
> <mapper namespace="com.webt.mapper.UserMapper">
>   <resultMap id="userResultMap" type="User">
>     <id property="id" column="Id" />
>     <result property="name" column="Name"/>
>     <result property="passwordHashValue" column="PasswordHashValue"/>
>     <result property="email" column="Email"/>
>     <result property="phone" column="Phone"/>
>     <result property="address" column="Address"/>
>     <result property="gender" column="Sex"/>
>     <result property="active" column="Active"/>
>   </resultMap>
>   <select id="getUser" parameterType="User" resultMap="userResultMap" >
>     select Id,PasswordHashValue,Salt,Name,Email,Phone,Address,Sex,Active
> from User where Name = #{name} or Email = #{email}
>   </select>
>   <select id="getAllUsers" resultMap="userResultMap" >
>     select * from User
>   </select>
> ...
> </mapper>
>
> Another important xml file is under /src/main/resources folder
> mybatisConfig.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
> "http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
> <configuration>
>   <typeAliases>
>     <typeAlias alias="User" type="com.webt.user.User"/>
>     <typeAlias alias="LoginRecord" type="com.webt.user.LoginRecord"/>
>     <typeAlias alias="LoginFailedInfo"
> type="com.webt.user.LoginFailedInfo"/>
>     <typeAlias alias="Display" type="com.webt.data.Display"/>
>     <typeAlias alias="Data" type="com.webt.data.Data"/>
>     <typeAlias alias="DataBlock" type="com.webt.data.DataBlock"/>
>     <typeAlias alias="EmailSender" type="com.webt.email.EmailSender"/>
>     <typeAlias alias="Role" type="com.webt.user.Role"/>
>   </typeAliases>
>   <mappers>
>     <mapper resource="map/UserMapper.xml" />
>     <mapper resource="map/DisplayMapper.xml" />
>     <mapper resource="map/EmailSettingMapper.xml" />
>   </mappers>
> </configuration>
>
> The last thing is to configure the applicationContext.xml for spring now.
> It lies in src/main/webapp/WEB-INF folder.
> <?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:context="http://www.springframework.org/schema/context"
>        xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>   http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd">
>   <context:annotation-config/>
>
>   <context:component-scan base-package="com.webt"/>
>   <bean
> class="org.springframework.beans.factory.config.CustomScopeConfigurer">
>     <property name="scopes">
>       <map>
> <entry key="view">
>  <bean class="com.webt.scope.ViewScope"/>
> </entry>
>       </map>
>     </property>
>   </bean>
>   <bean
> class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
>   <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource"
> destroy-method="close">
>     <property name="driverClass" value="com.mysql.jdbc.Driver" />
>     <property name="jdbcUrl"
> value="jdbc:mysql://192.168.0.110:3306/fucai?zeroDateTimeBehavior=convertToNull&amp;characterEncoding=utf8&amp;useConfigs=maxPerformance&amp;useDynamicCharsetInfo=false&amp;useUnicode=true&amp;autoReconnect=true"
> />
>     <property name="username" value="freebird"/>
>     <property name="password" value="770328"/>
>     <property name="idleConnectionTestPeriod" value="60"/>
>     <property name="idleMaxAge" value="240"/>
>     <property name="maxConnectionsPerPartition" value="30"/>
>     <property name="minConnectionsPerPartition" value="10"/>
>     <property name="partitionCount" value="3"/>
>     <property name="acquireIncrement" value="5"/>
>     <property name="statementsCacheSize" value="100"/>
>     <property name="releaseHelperThreads" value="3"/>
>   </bean>
>
>   <bean id="transactionManager"
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>     <property name="dataSource" ref="dataSource"/>
>   </bean>
>
>   <bean id="sqlSessionFactory"
> class="org.mybatis.spring.SqlSessionFactoryBean">
>     <property name="dataSource" ref="dataSource" />
>     <property name="configLocation" value="classpath:mybatisConfig.xml"/>
>   </bean>
>   <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
>     <property name="basePackage" value="com.webt.mapper" />
>   </bean>
>
> </beans>
> Let me know if you still have questions.Also,I suggest using BoneCP as your
> connection pool.
> 陈抒
> Best regards
> http://blog.csdn.net/sheismylife
>
>
> On Mon, Feb 28, 2011 at 11:06 PM, Eduardo <[hidden email]>
> wrote:
>>
>> How are you getting your MenuInfoService from the Spring context in
>> MainMenuComposer?
>
>
Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

陈抒
When I developed VC++ applications on Windows ten years ago.Microsoft provided a lot of documents to show how to use its framework step by step.
I mean the MyBatis community needs some wizard documents that help  many people to learn it step by step too. This will be very helpful for the popularization of MyBatis.

陈抒
Best regards
http://blog.csdn.net/sheismylife


On Mon, Feb 28, 2011 at 11:43 PM, Simone Tripodi <[hidden email]> wrote:
Ni hao 陈抒
examples *are* available on MyBatis repository:

[1] simple example: http://tinyurl.com/5upkxdn
[2] JPetStore 6: http://tinyurl.com/6y6m5ln

Zai jihan,
On Mon, Feb 28, 2011 at 4:36 PM, 陈抒 <[hidden email]> wrote:
> If we have one example which shows how to configure spring with mybatis,that
> will save a lot of time for  everyone.
> I ran into the same problem before,I will show how I configure it here.
> My project is a JSF2(with PrimeFaces)+Spring3.0.5+MyBatis3.0.4,using
> Maven3.0.2,glassfish on UBuntu.
> I have a login.xhtml page,also has a pagebean named Login.java in
> com.webt.pagebean package.
> @Component
> @Lazy(true)
> @Scope("view")
> public class Login implements Serializable{
> ....
>   @Autowired
>   private transient UserService service;
> ...
> }
> When the browser requests login.xhtml file,JSF and Spring runtime work
> together to create a Login object,because the UserSerivce is a @Autowired
> property,the Spring runtime will create a UserService object and call
> Login.setService method.
> UserService.java is under com.webt.service package
> @Service(value="com.webt.service.UserService")
> @Lazy(true)
> public class UserService{
> ...
>   @Autowired
>   private UserMapper userMapper;
> ...
> }
> In the same way,Sprint will try to create a UserMapper object and call
> UserService.setUserMapper method.UserMapper is an interface and
> Sprint-MyBatis library will implement it.This interfaces contains all
> methods corresponding the SQL templates in xml file.
> UserMapper.java is under com.webt.map package
> public interface UserMapper {
>
>   public User getUser(User user);
>   public User getUserByEmail(User user);
> ...
> }
> In my maven web project,all xml files that contain SQL templates are in
> /src/main/resources/map folder.
> UserMapper.xml looks like so:
> <mapper namespace="com.webt.mapper.UserMapper">
>   <resultMap id="userResultMap" type="User">
>     <id property="id" column="Id" />
>     <result property="name" column="Name"/>
>     <result property="passwordHashValue" column="PasswordHashValue"/>
>     <result property="email" column="Email"/>
>     <result property="phone" column="Phone"/>
>     <result property="address" column="Address"/>
>     <result property="gender" column="Sex"/>
>     <result property="active" column="Active"/>
>   </resultMap>
>   <select id="getUser" parameterType="User" resultMap="userResultMap" >
>     select Id,PasswordHashValue,Salt,Name,Email,Phone,Address,Sex,Active
> from User where Name = #{name} or Email = #{email}
>   </select>
>   <select id="getAllUsers" resultMap="userResultMap" >
>     select * from User
>   </select>
> ...
> </mapper>
>
> Another important xml file is under /src/main/resources folder
> mybatisConfig.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
> "http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
> <configuration>
>   <typeAliases>
>     <typeAlias alias="User" type="com.webt.user.User"/>
>     <typeAlias alias="LoginRecord" type="com.webt.user.LoginRecord"/>
>     <typeAlias alias="LoginFailedInfo"
> type="com.webt.user.LoginFailedInfo"/>
>     <typeAlias alias="Display" type="com.webt.data.Display"/>
>     <typeAlias alias="Data" type="com.webt.data.Data"/>
>     <typeAlias alias="DataBlock" type="com.webt.data.DataBlock"/>
>     <typeAlias alias="EmailSender" type="com.webt.email.EmailSender"/>
>     <typeAlias alias="Role" type="com.webt.user.Role"/>
>   </typeAliases>
>   <mappers>
>     <mapper resource="map/UserMapper.xml" />
>     <mapper resource="map/DisplayMapper.xml" />
>     <mapper resource="map/EmailSettingMapper.xml" />
>   </mappers>
> </configuration>
>
> The last thing is to configure the applicationContext.xml for spring now.
> It lies in src/main/webapp/WEB-INF folder.
> <?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:context="http://www.springframework.org/schema/context"
>        xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>   http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd">
>   <context:annotation-config/>
>
>   <context:component-scan base-package="com.webt"/>
>   <bean
> class="org.springframework.beans.factory.config.CustomScopeConfigurer">
>     <property name="scopes">
>       <map>
> <entry key="view">
>  <bean class="com.webt.scope.ViewScope"/>
> </entry>
>       </map>
>     </property>
>   </bean>
>   <bean
> class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
>   <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource"
> destroy-method="close">
>     <property name="driverClass" value="com.mysql.jdbc.Driver" />
>     <property name="jdbcUrl"
> value="jdbc:mysql://192.168.0.110:3306/fucai?zeroDateTimeBehavior=convertToNull&amp;characterEncoding=utf8&amp;useConfigs=maxPerformance&amp;useDynamicCharsetInfo=false&amp;useUnicode=true&amp;autoReconnect=true"
> />
>     <property name="username" value="freebird"/>
>     <property name="password" value="770328"/>
>     <property name="idleConnectionTestPeriod" value="60"/>
>     <property name="idleMaxAge" value="240"/>
>     <property name="maxConnectionsPerPartition" value="30"/>
>     <property name="minConnectionsPerPartition" value="10"/>
>     <property name="partitionCount" value="3"/>
>     <property name="acquireIncrement" value="5"/>
>     <property name="statementsCacheSize" value="100"/>
>     <property name="releaseHelperThreads" value="3"/>
>   </bean>
>
>   <bean id="transactionManager"
> class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>     <property name="dataSource" ref="dataSource"/>
>   </bean>
>
>   <bean id="sqlSessionFactory"
> class="org.mybatis.spring.SqlSessionFactoryBean">
>     <property name="dataSource" ref="dataSource" />
>     <property name="configLocation" value="classpath:mybatisConfig.xml"/>
>   </bean>
>   <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
>     <property name="basePackage" value="com.webt.mapper" />
>   </bean>
>
> </beans>
> Let me know if you still have questions.Also,I suggest using BoneCP as your
> connection pool.
> 陈抒
> Best regards
> http://blog.csdn.net/sheismylife
>
>
> On Mon, Feb 28, 2011 at 11:06 PM, Eduardo <[hidden email]>
> wrote:
>>
>> How are you getting your MenuInfoService from the Spring context in
>> MainMenuComposer?
>
>

Reply | Threaded
Open this post in threaded view
|

Re: mybatis MapperScannerConfigurer

Eduardo Macarron
In reply to this post by erha
The setter I was suggesting would look like this:

@Service
public class MenuInfoService
{
       private MenuInfoMapper menuInfoMapper;

       @Autowired
       public setMenuInfoMapper(MenuInfoMapper newMapper){
          menuInfoMapper=newMapper;
       }

       public String getDisplay()
       {
               return menuInfoMapper.getDisplay();
       }
}

Look that @autowired is mandatory.

That will let you set a breakpoint and see what happens.

12