发表于: 2017-09-16 23:49:57

1 817


今天完成的事

【1】按着昨天搭建的Spring方法怎么都搭不上,各种报错,换了个博客技术贴重新来。

【2】按着师兄的方法重新搭建了一下spring,这次用的maven的框架pom.xml

<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>3.2.10.RELEASE</version>
</dependency>

<dependency>
   <groupId>org.springframework.webflow</groupId>
   <artifactId>spring-webflow</artifactId>
   <version>2.4.0.RELEASE</version>
</dependency>

<dependency>
   <groupId>org.springframework.data</groupId>
   <artifactId>spring-data-oracle</artifactId>
   <version>1.0.0.RELEASE</version>
</dependency>

<dependency>
   <groupId>org.mybatis</groupId>
   <artifactId>mybatis</artifactId>
   <version>3.2.4</version>
</dependency>

<dependency>
   <groupId>org.mybatis</groupId>
   <artifactId>mybatis-spring</artifactId>
   <version>1.2.2</version>

</dependency>       

<dependency>
   <groupId>com.oracle</groupId>
   <artifactId>ojdbc14</artifactId>
   <version>10.2.0.4.0</version>
</dependency>


【3】先按着博客编写spring-mybatis.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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
      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">

   <!-- 引入dbconfig.properties属性文件 -->
   <context:property-placeholder location="classpath:dbconfig.properties"/>

   <!--配置数据源,这里可以换成C3P0,DBCP等等其他的链接方式-->
   <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
       <property name="driverClassName" value="${driverClassName}"/>
       <property name="url" value="${jdbc_url}"/>
       <property name="username" value="${jdbc_username}"/>
       <property name="password" value="${jdbc_password}"/>
   </bean>

   <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
       <property name="dataSource" ref="dataSource"/>
       <property name="mapperLocations" value="classpath:com/gcoreinc/dao/*Mapper.xml"/>
       <property name="typeAliasesPackage" value="com.gcoreinc.domain"/>
   </bean>
   <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
       <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
       <property name="basePackage" value="com.gcoreinc.dao"/>
   </bean>
</beans>

遇到的问题

【1】

<dependency>
   <groupId>com.oracle</groupId>
   <artifactId>ojdbc14</artifactId>
   <version>10.2.0.4.0</version>
</dependency>

这样加载orcal这个配置文件不能加载,

解决方法

我就去官网下了个包,解压然后加载的。

收获

对着Spring开始写配置文件,逐渐分析每个代码的用处。

明天要做的事

【1】接着搭建Spring


返回列表 返回列表
评论

    分享到