ssh 使用@autowired注入的对象为什么会是空的?

junYuQiao 2017-07-04 01:40:11
<?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"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
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/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd"
>
<!-- 全局配置,跟平台和部署无关 -->
<!-- 使用 annotation 自动注册bean,并检查@Controller, @Service, @Repository注解已被注入 -->
<!-- 指定搜索模块的目录 -->
<context:component-scan base-package="com.common,com.biz,com.sysManage,com.sysInterface" />
<!-- hibernate属性配置 -->
<context:annotation-config />


<context:property-placeholder location="classpath:hibernate/hibernate.properties" ignore-unresolvable="true"/>

<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="${hibernate.connection.driver_class}"></property>
<property name="url" value="${hibernate.connection.url}"></property>
<property name="username" value="${hibernate.connection.username}"></property>
<property name="password" value="${hibernate.connection.password}"></property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><!-- .annotation.AnnotationSessionFactoryBean -->
<property name="dataSource" ref="dataSource" />
<!-- <property name="packagesToScan" value="com.**.domain"/> -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/sysManage/domain/</value>
<value>classpath:com/common/domain/</value>
<value>classpath:com/biz/gis/domain/</value>
<value>classpath:com/biz/petition/domain/</value>
<value>classpath:com/sysInterface/domain/</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<!-- <prop key="hibernate.generate_statistics">true</prop> -->
<prop key="hibernate.connection.release_mode">${hibernate.connection.release_mode}</prop>
<prop key="hibernate.autoReconnect">${hibernate.autoReconnect}</prop>
<!-- <prop key="hibernate.hbm2ddl.auto">update</prop> -->
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache/ehcache.xml</prop>

<prop key="hibernate.c3p0.max_size">20</prop>
</props>
</property>
</bean>
</beans>


...全文
372 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
junYuQiao 2017-07-06
  • 打赏
  • 举报
回复
谢谢 我现在已经解决了
qq_16566893 2017-07-04
  • 打赏
  • 举报
回复
如果直接new对象的话,注入到对象里面的接口是空的。
晨曦遇晓 2017-07-04
  • 打赏
  • 举报
回复
请把问题的代码和异常贴出来

50,530

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧