目录
(1)建立空项目
(2)建立一个模块:maven项目
(3)建立测试类app.class
(4)在l导入spring的两个坐标
(5)建立配置文件l
🌞哈喽,大家好丫,你们的小郭子又来啦 ~
话不多说,直接上干货,嘻嘻嘻 ~
import com.itheima.dao.BookDao;
import com.itheima.service.BookService;
import t.ApplicationContext;
import t.support.ClassPathXmlApplicationContext;public class App2 {public static void main(String[] args) {//获取ioc容器ApplicationContext ctx=new ClassPathXmlApplicationContext(l");//获取bean
// BookDao bookdao = (BookDao) Bean("bookdao1");
// bookdao.save();BookService bookservice= (BookService) Bean("bookservice1");bookservice.save();}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0"xmlns:xsi=""xsi:schemaLocation=".0.0 .0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId&le</groupId><artifactId>springioc</artifactId><version>1.0-SNAPSHOT</version><dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.2.10.RELEASE</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency></dependencies></project>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""xmlns:xsi=""xsi:schemaLocation=" .xsd"><!-- 配置bean、--><bean id="bookdao1" class="com.itheima.dao.impl.BookDaoimpl"/><bean id="bookservice1" class="com.itheima.service.impl.BookServiceimpl"/>
</beans>
好啦,今天的分享到这里就结束啦 ~🌞🌞
觉得我分享的文章不错的话,可以关注一下哦,嘻嘻嘻🌞🌞
本文发布于:2024-02-01 12:33:50,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170676202936625.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |