Spring 的autowired大坑

---恢复内容开始---

@autowired

自动注入大坑

这几天在spring的配置上花了许多时间....

首先appcontextconfig.xml

配置还是根据官方得来没有错的

 >>>>>>>>>>>>>>>>>>>>>如下>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>

>>>>

>>

>


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">









 

















class="org.springframework.jdbc.datasource.DataSourceTransactionManager">









cache-period="864000" />







 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>

>>>>>>>>
>>>>>>..

>>>>>

>>>

>>

>

 

紧接着呢

》》》

开始写dao层

首先我要说明下其实交给spring管理了,就没有必要自己实现dao接口了

mybatis的mapper就相当于dao层了,,,

接着都是spring的事了

然后嘞就是啥呢

然后开始注入service层

@autowired的mapper

service层自动注入了mapper

那么使用service的地方也要@autowired 这个service

autowired 不能断,要一直应用下去

不然会爆空指针错误  这里指的是 mapper

哈哈哈哈哈哈哈

 

期间呢还发生了需要故事

如果报了 logger 啥的错误  type different class类似字眼记得

把tomcat下bin的commed log 。jar删了

 

xxiixixixixixihahahaha

哈哈哈哈

转载于:https://www.cnblogs.com/zhangtalent/p/8450085.html

你可能感兴趣的:(Spring 的autowired大坑)