OSGI企业应用开发(九)整合Spring和Mybatis框架(二)
来源:互联网 发布:系统矩阵不可逆 编辑:程序博客网 时间:2024/06/06 02:57
上篇文章中,我们完成了在OSGI应用中整合spring和Mybatis框架的准备工作,本节我们继续Spring和Mybatis框架的整合。
一、解决OSGI整合Spring中的Placeholder问题
使用Spring框架的朋友应该都知道,我们可以在Bean的配置文件中,使用${key}的形式访问properties文件中对应的value值,需要用到Spring中的PropertyPlaceholderConfigurer类,使用方式如下,首先需要配置placeholder,例如:
<bean id="placeholder"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>conf/jdbc.properties</value> </property></bean>
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
conf/jdbc.properties文件内容如下:
jdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost/mysqldb?useUnicode=true&characterEncoding=UTF-8&jdbc.username=rootjdbc.password=123456
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
然后我们定义Bean的时候,就可以使用${key}的方式访问jdbc.properties文件中的内容,例如:
<bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"> <property name="driverClassName"value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}"/> <property name="password"value="${jdbc.password}" /></bean>
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
但是在OSGI应用中,并没有全局的Classpath的概念,其中一个Bundle的属性文件在其他Bundle中无法访问,而且不同Bundle中的ApplictionContext也是独立的,PropertyPlaceholderConfigurer实例在不同的Bundle中不是共享的,所以Spring框架中的Placeholder配置也就存在一定的问题。
Gemini Blueprint为OSGI应用中使用Placeholder提供了一种解决方案,但是基于Key-Value的配置信息需要定义在XML文件中,例如:
<?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:osgix="http://www.springframework.org/schema/osgi-compendium" xmlns:ctx="http://www.springframework.org/schema/context" xmlns:osgi="http://www.eclipse.org/gemini/blueprint/schema/blueprint" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd http://www.eclipse.org/gemini/blueprint/schema/blueprint http://www.eclipse.org/gemini/blueprint/schema/blueprint/gemini-blueprint.xsd"> <osgix:cm-properties id="dbInfo" persistent-id="com.csdn.osgi.common"> <prop key="driver">com.mysql.jdbc.Driver</prop> <prop key="url">jdbc:mysql://127.0.0.1:3306/osgi</prop> <prop key="username">root</prop> <prop key="password"></prop> </osgix:cm-properties> <ctx:property-placeholder properties-ref="dbInfo" /></beans>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
接下来在Bean的定义中,就可以一${Key}的形式访问Value值了,例如:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> </bean>
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
二、Spring与Mybatis框架整合
1、首先新建一个Plug-in Project,名称为com.csdn.osgi.database,该Bundle用于操作数据库。
2、接着在com.csdn.osgi.database工程中新建META-INF/spring目录,然后在该目录下新建database.xml文件,用于配置数据源及Mybatis-Spring插件提供的SqlSessionFactoryBean和SqlSessionTemplate的实例,以及事务管理器等。
database.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:sqlMap.xml"/> </bean> <!-- 创建SqlSessionTemplate --> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean> <!-- 事务管理 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!--事务模板 --> <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"> <property name="transactionManager"> <ref local="transactionManager" /> </property> <!--ISOLATION_DEFAULT 表示由使用的数据库决定 --> <property name="isolationLevelName" value="ISOLATION_DEFAULT"/> <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/> </bean> </beans>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
3、接下来在META-INF/spring目录下,新建一个dmconfig.xml文件,用于配置placeholder及注册sqlSessionTemplate这个Bean,这样在其他Bundle中就可以通过引用我们注册的sqlSessionTemplate来操作数据库了。
dmconfig.xml文件内容如下:
<?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:osgix="http://www.springframework.org/schema/osgi-compendium" xmlns:ctx="http://www.springframework.org/schema/context" xmlns:osgi="http://www.eclipse.org/gemini/blueprint/schema/blueprint" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd http://www.eclipse.org/gemini/blueprint/schema/blueprint http://www.eclipse.org/gemini/blueprint/schema/blueprint/gemini-blueprint.xsd"> <osgix:cm-properties id="dbInfo" persistent-id="com.csdn.osgi.common"> <prop key="driver">com.mysql.jdbc.Driver</prop> <prop key="url">jdbc:mysql://127.0.0.1:3306/osgi</prop> <prop key="username">root</prop> <prop key="password"></prop> </osgix:cm-properties> <ctx:property-placeholder properties-ref="dbInfo" /> <osgi:service id="sqlMapService" ref="sqlSessionTemplate" interface="org.apache.ibatis.session.SqlSession" /></beans>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
4、接下来就是Mybatis主配置文件和SQL的配置了,在sqlSessionFactory这个Bean的配置中,我们指定了Mybatis配置文件为sqlMap.xml,如下:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:sqlMap.xml"/> </bean>
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
所以需要在com.csdn.osgi.database工程的src目录下新建一个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="user.xml"/> </mappers></configuration>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
上面配置中,我们指定了SQL配置文件为user.xml,接着在com.csdn.osgi.database工程的src目录下新建user.xml文件,内容如下:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="user"> <insert id="saveUser" parameterType="java.util.HashMap"> insert into user(username,password) values(#{UserName},#{Password}); </insert> <select id="getPasswordByName" parameterType="java.lang.String" resultType="java.lang.String"> select password from user where username = #{UserName} </select></mapper>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
5、整个工程目录及文件结构如下图所示:
6、然后还需要对com.csdn.osgi.database工程的MANIFEST.MF文件新建修改,添加如下Bundle的依赖:
Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-Name: DatabaseBundle-SymbolicName: com.csdn.osgi.databaseBundle-Version: 1.0.0.qualifierBundle-Vendor: CSDNBundle-RequiredExecutionEnvironment: JavaSE-1.8Require-Bundle: org.springframework.jdbc;bundle-version="3.0.0", org.mybatis.mybatis;bundle-version="3.1.1", com.springsource.org.apache.commons.dbcp;bundle-version="1.2.2", com.springsource.org.apache.commons.pool;bundle-version="1.3.0", org.springframework.transaction;bundle-version="3.0.0", com.springsource.com.mysql.jdbc;bundle-version="5.1.6", org.mybatis.mybatis-spring;bundle-version="1.2.3"
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
上面MANIFEST.MF文件中,Require-Bundle元数据头为新增。
7、最后一步,启动OSGI容器。需要单击Run=>Debug Configurations…菜单,如下图所示:
单击Validate Bundles按钮,查看是否存在Bundle依赖问题,笔者单击后如下图所示:
说明存在依赖问题,解决方法非常简单,单击面板上的Add Required Bundles按钮即可。
启动后输出控制台输出日志内容如下:
一月 07, 2017 3:40:33 下午 org.eclipse.gemini.blueprint.extender.internal.boot.ChainActivator <init>信息: Blueprint API detected; enabling Blueprint Container functionality一月 07, 2017 3:40:33 下午 org.eclipse.gemini.blueprint.extender.internal.activator.LoggingActivator start信息: Starting [org.eclipse.gemini.blueprint.extender] bundle v.[2.0.0.M02]osgi> 一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration start信息: No custom extender configuration detected; using defaults...一月 07, 2017 3:40:34 下午 org.springframework.scheduling.timer.TimerTaskExecutor afterPropertiesSet信息: Initializing Timerhello world!一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.support.DefaultOsgiApplicationContextCreator createApplicationContext信息: Discovered configurations {osgibundle:/META-INF/spring/*.xml} in bundle [Common (com.csdn.osgi.common)]Hello World!!一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.support.DefaultOsgiApplicationContextCreator createApplicationContext信息: Discovered configurations {config/*.xml} in bundle [Helloworld (com.csdn.osgi.helloworld)]一月 07, 2017 3:40:34 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh信息: Refreshing OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.common, config=osgibundle:/META-INF/spring/*.xml): startup date [Sat Jan 07 15:40:34 CST 2017]; root of context hierarchy一月 07, 2017 3:40:34 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh信息: Refreshing OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.helloworld, config=config/*.xml): startup date [Sat Jan 07 15:40:34 CST 2017]; root of context hierarchy一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext unpublishContextAsOsgiService信息: Application Context service already unpublished一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.support.BlueprintContainerCreator createApplicationContext信息: Discovered configurations {bundleentry://43.fwk2082351774/OSGI-INF/blueprint/beans.xml} in bundle [Helloworld (com.csdn.osgi.helloworld)]一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext unpublishContextAsOsgiService信息: Application Context service already unpublished一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.support.DefaultOsgiApplicationContextCreator createApplicationContext信息: Discovered configurations {osgibundle:/META-INF/spring/*.xml} in bundle [Database (com.csdn.osgi.database)]一月 07, 2017 3:40:34 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh信息: Refreshing OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.database, config=osgibundle:/META-INF/spring/*.xml): startup date [Sat Jan 07 15:40:34 CST 2017]; root of context hierarchy一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext unpublishContextAsOsgiService信息: Application Context service already unpublished一月 07, 2017 3:40:34 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh信息: Refreshing OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.helloworld, config=bundleentry://43.fwk2082351774/OSGI-INF/blueprint/beans.xml): startup date [Sat Jan 07 15:40:34 CST 2017]; root of context hierarchy一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext unpublishContextAsOsgiService信息: Application Context service already unpublished一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from OSGi resource[bundleentry://43.fwk2082351774/OSGI-INF/blueprint/beans.xml|bnd.id=43|bnd.sym=com.csdn.osgi.helloworld]一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://37.fwk2082351774/META-INF/spring/beans.xml]一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://46.fwk2082351774/META-INF/spring/database.xml]一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://43.fwk2082351774/config/beans.xml]一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://43.fwk2082351774/config/company.xml]一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://46.fwk2082351774/META-INF/spring/dmconfig.xml]一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://37.fwk2082351774/META-INF/spring/dmconfig.xml]一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor stageOne信息: No outstanding OSGi service dependencies, completing initialization for OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.helloworld, config=bundleentry://43.fwk2082351774/OSGI-INF/blueprint/beans.xml)一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://43.fwk2082351774/config/dmconfig.xml]================Hello World================一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from URL [bundleentry://37.fwk2082351774/META-INF/spring/employee.xml]一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@215dd7af: defining beans [helloWorld,blueprintBundle,blueprintBundleContext,blueprintContainer,blueprintConverter]; root of factory hierarchy一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor stageOne信息: No outstanding OSGi service dependencies, completing initialization for OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.common, config=osgibundle:/META-INF/spring/*.xml)一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.blueprint.container.support.BlueprintContainerServicePublisher registerService信息: Publishing BlueprintContainer as OSGi service with properties {Bundle-SymbolicName=com.csdn.osgi.helloworld, Bundle-Version=1.0.0.qualifier, osgi.blueprint.container.version=1.0.0.qualifier, osgi.blueprint.container.symbolicname=com.csdn.osgi.helloworld}一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@68bf15f1: defining beans [object,length,buffer,current-time,list,employee,programmer]; root of factory hierarchy一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext publishContextAsOsgiServiceIfNecessary信息: Publishing application context as OSGi service with properties {org.eclipse.gemini.blueprint.context.service.name=com.csdn.osgi.helloworld, org.springframework.context.service.name=com.csdn.osgi.helloworld, Bundle-SymbolicName=com.csdn.osgi.helloworld, Bundle-Version=1.0.0.qualifier}一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyServiceManager doFindDependencies信息: Adding OSGi service dependency for importer [&employee] matching OSGi filter [(objectClass=com.csdn.osgi.domain.Employee)]一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.support.DefaultOsgiBundleApplicationContextListener onOsgiApplicationEvent信息: Application context successfully refreshed (OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.helloworld, config=bundleentry://43.fwk2082351774/OSGI-INF/blueprint/beans.xml))一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyServiceManager findServiceDependencies信息: OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.helloworld, config=config/*.xml) is waiting for unsatisfied dependencies [[&employee]]一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor stageOne信息: No outstanding OSGi service dependencies, completing initialization for OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.database, config=osgibundle:/META-INF/spring/*.xml)一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@30d1126b: defining beans [dataSource,sqlSessionFactory,sqlSessionTemplate,transactionManager,transactionTemplate,dbInfo,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,sqlMapService]; root of factory hierarchy一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean registerService信息: Publishing service under classes [{com.csdn.osgi.domain.Employee}]一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyServiceManager$DependencyServiceListener serviceChanged信息: No unsatisfied OSGi service dependencies; completing initialization for OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.helloworld, config=config/*.xml)一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext publishContextAsOsgiServiceIfNecessary信息: Publishing application context as OSGi service with properties {org.eclipse.gemini.blueprint.context.service.name=com.csdn.osgi.common, org.springframework.context.service.name=com.csdn.osgi.common, Bundle-SymbolicName=com.csdn.osgi.common, Bundle-Version=1.0.0.qualifier}一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.support.DefaultOsgiBundleApplicationContextListener onOsgiApplicationEvent信息: Application context successfully refreshed (OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.common, config=osgibundle:/META-INF/spring/*.xml))SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.一月 07, 2017 3:40:34 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4f805c92: defining beans [helloWorld1,helloWorld2,company,employee]; root of factory hierarchy================Hello World================================Hello World=========================Company=========一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext publishContextAsOsgiServiceIfNecessary信息: Publishing application context as OSGi service with properties {org.eclipse.gemini.blueprint.context.service.name=com.csdn.osgi.helloworld, org.springframework.context.service.name=com.csdn.osgi.helloworld, Bundle-SymbolicName=com.csdn.osgi.helloworld, Bundle-Version=1.0.0.qualifier}一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.support.DefaultOsgiBundleApplicationContextListener onOsgiApplicationEvent信息: Application context successfully refreshed (OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.helloworld, config=config/*.xml))一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean registerService信息: Publishing service under classes [{org.apache.ibatis.session.SqlSession}]一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext publishContextAsOsgiServiceIfNecessary信息: Publishing application context as OSGi service with properties {org.eclipse.gemini.blueprint.context.service.name=com.csdn.osgi.database, org.springframework.context.service.name=com.csdn.osgi.database, Bundle-SymbolicName=com.csdn.osgi.database, Bundle-Version=1.0.0.qualifier}一月 07, 2017 3:40:34 下午 org.eclipse.gemini.blueprint.extender.internal.support.DefaultOsgiBundleApplicationContextListener onOsgiApplicationEvent信息: Application context successfully refreshed (OsgiBundleXmlApplicationContext(bundle=com.csdn.osgi.database, config=osgibundle:/META-INF/spring/*.xml))
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
从日志文件中可以分析出,Mybatis相关的Bean已经实例化成功,本节内容先介绍这么多,下篇文件中我们在其他Bundle中通过Mybatis-Spring插件提供的模版类操作数据库。
注意:上篇文章提到使用Mybatis-Spring插件版本为1.2.0,与Spring 3.0整合存在一定的问题,本文中笔者將Mybatis-Spring插件版本改为1.2.3。
- OSGI企业应用开发(九)整合Spring和Mybatis框架(二)
- OSGI企业应用开发(九)整合Spring和Mybatis框架(二)
- OSGI企业应用开发(八)整合Spring和Mybatis框架(一)
- OSGI企业应用开发(十)整合Spring和Mybatis框架(三)
- OSGI企业应用开发(八)整合Spring和Mybatis框架(一)
- OSGI企业应用开发(十)整合Spring和Mybatis框架(三)
- OSGI企业应用开发(五)使用Blueprint整合Spring框架(二)
- OSGI企业应用开发(五)使用Blueprint整合Spring框架(二)
- OSGI企业应用开发(十四)整合Spring、Mybatis、Spring MVC
- OSGI企业应用开发(四)使用Blueprint整合Spring框架(一)
- OSGI企业应用开发(四)使用Blueprint整合Spring框架(一)
- OSGI企业应用开发(十五)基于Spring、Mybatis、Spring MVC实现一个登录应用
- OSGI企业应用开发(十三)OSGI Web应用开发(二)
- Spring MVC+Mybatis 框架整合(二)
- OSGI企业应用开发(一)OSGI简介
- OSGI企业应用开发(一)OSGI简介
- Mybatis系列(九)Spring & Mybatis整合
- spring整合使用持久层框架mybatis(二)
- 第四题:根据前序和中序遍历结果重建二叉树(Arrays常用方法)
- J2EE进阶之javascript 三
- microsoft word中在公式后插入可交叉引用的公式编号
- spring OAuth 2 Developers Guide 英译汉
- ARP协议与RARP协议
- OSGI企业应用开发(九)整合Spring和Mybatis框架(二)
- 使用SpringBoot yml配置文件(三)
- Java基础——overload(重载)与overwrite(重写)的区别
- 机器学习实战-第三章(决策树)
- iOS客户端 与JAVA 后台http通信
- 微信小程序开发—(五)弹出框
- 各种机器学习的应用场景
- 函数的调用
- 解决java项目打成jar包之后,GUI界面的logo无法显示问题