3110人加入学习
(9人评价)
SSM框架第二季 - Spring入门

制作完成于2018-09-06 使用Eclipse-4.7.3a、JDK8、Spring-5.0.8、Mybatis-3.4.6

价格 免费

报错:

BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

原因:

使用ApplicationContext ac=new ClassPathXmlApplicationContext();的时候没有传递参数

改为

ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");

 

 

注意获取容器的时候一定要传递容器对应的配置文件

[展开全文]

在applicationContext.xml中配置:

<!-- 配置dataSource -->
<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="com.mysql.cj.jdbc.Driver"/>
    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssm_spring?useUnicode=true&amp;characterEncoding=utf-8&amp;serverTimezone=GMT"/>
    <property name="user" value="root"/>
    <property name="password" value="root"/>
</bean>

<!-- 配置dao -->
<bean name="userDao" class="com.lingzhihao.dao.UserDaoImpl">
    <property name="dataSource" ref="dataSource"/>

</bean>
<!-- 配置service -->
<bean name="userService" class="com.lingzhihao.service.UserServiceImpl">
    <property name="ud" ref="userDao"/>
</bean>

[展开全文]

授课教师

SIKI学院老师

课程特色

下载资料(1)
视频(36)

学员动态