你注入的值有问题,你好好检查下。不行你把你的配置都贴出来,那就可以找到原因。要不你参考一下,
http://www.cnweblog.com/kestrel/archive/2006/04/05/95957.html
这个,然后好好理解一下。
http://www.cnweblog.com/kestrel/archive/2006/04/05/95957.html
这个,然后好好理解一下。
解决方案 »
- SPRING2.0+ow2-jotm-dist-2.2.1 经常找不获取不到数据源连接但是刷新一下就好了
- 关于spring注入抽象类问题
- struts中的是必要的吗
- 页面显示 按格式显示。
- jar与vista的兼容性问题
- Mysql数据库取值问题
- 请教各位大虾,一边是一家外包公司,但是去了是作一个比较大的java项目,一边是腾讯,去了作游戏测试,作java开发的工资还比腾讯的高700块左右
- struts2上传图片并显示出来
- 一个hibernte+struts的问题,ide是jbuilder,服务器是resin,高手帮我看看!!
- junit测试的方法调用了JNDI,总是出错......
- 大虾们,救救我吧,一个简单的问题。
- 获取ACCESS数据库时间字段值的问题
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><!--通过spring的配置文件
1。 减少了多个配置文件对于调动的干扰
2。 充分利用框架里面的代码实现对于数据库的基本连接(JDBC或者是HIBERNATE等ORM的连接)。
3。 充分利用SPRING自带的事务管理机制来确保连接时候的事务处理
-->
<!--
- Application context definition 项目文档注释开头部分 (这个是针对Hibernate的)
-->
<beans>
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<!-- 如果配置文件放在properties文件里面
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/jdbc.properties"/>
</bean>
-->
<!-- Local DataSource that works in any environment -->
<!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->
<!-- See JPetStore for an example of using Commons DBCP BasicDataSource as alternative -->
<!-- See Image Database for an example of using C3P0 ComboPooledDataSource as alternative -->
<!--DataSource definition -->
<!--DataSource Connection based on spring itself-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.gjt.mm.mysql.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/security"/>
<property name="username" value="root"/>
<property name="password" value="zbw2006"/>
</bean>
<!--DataSource connection based on apache iteself-->
<!--
<bean id = "dataSource"
class ="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>org.gjt.mm.mysql.Driver</value>
</property>
<property name ="url">
<value>jdbc:mysql://localhost:3306/security</value>
</property>
<property name = "username">
<value>root</value>
</property>
<property name ="password">
<value>password</value>
</property>
</bean>
-->
<!-- JNDI DataSource for J2EE environments -->
<!--
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/petclinic"/>
</bean>
-->
<!--SessionFactory defintion-->
<!--The most standard configuration according to hibernate3-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<value>com/itsz/hibernate/resources/account.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
</props>
</property>
<property name="eventListeners">
<map>
<entry key="merge">
<bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
</entry>
</map>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
<!--
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
-->
<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
<!--central data access object: Hibernate implementation.
-->
<bean id ="accountDAO"
class = "com.itsz.hibernate.dao.AccountDAO">
<property name ="sessionFactory" ref="sessionFactory" />
</bean>
<!--
- Transactional proxy for the project's central data access object.
-
- Defines specific transaction attributes with "readOnly" ers,
- which is an optimization that is particularly valuable with Hibernate
- (to suppress unnecessary flush attempts for read-only operations).
-
- Note that in a real-life app with multiple transaction proxies,
- you will probably want to use parent and child bean definitions
- as described in the manual, to reduce duplication.
-->
<!--If those prepared well we can rely the transferway to realize it -->
<bean id = "accountDAOProxy"
class = "org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<!-- such will refer to transactionManager -->
<property name="transactionManager" ref="transactionManager"/>
<property name="target" ref="accountDAO"/>
<!--such means that we would define the ways in userDAO transaction
it will execute the arrange towards insert~ or get~-->
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="get*">>PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<!-- Hibernate 3.0's JMX statistics service -->
<!-- Implements the StatisticsServiceMBean management interface -->
<bean name="database:type=HibernateStatistics" class="org.hibernate.jmx.StatisticsService">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- ========================= JMX EXPORTER DEFINITION ========================= --> <!--
- Exporter that exposes Hibernate 3.0's statistics service via JMX.
- Autodetects the statistics service, which is a standard MBean,
- using its bean name as JMX object name.
-
- By default, the standard MBeanServerFactory.findMBeanServer method will be used
- to determine the MBeanServer. Unfortunately, this does not work on WebLogic <= 8.1:
- you need to comment in the WebLogicMBeanServerFactoryBean definition on WebLogic,
- specifying appropriate configuration values there.
-->
<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="autodetect" value="true"/>
<!-- Comment the following in on WebLogic <= 8.1, which doesn't support -->
<!-- the standard MBeanServerFactory.findMBeanServer lookup mechanism. -->
<!--
<property name="server">
<bean class="org.springframework.jmx.support.WebLogicJndiMBeanServerFactoryBean"/>
</property>
-->
</bean>
</beans>