搜索
首页
笔记
案例
关于
课程列表
Spring
IOC
入门---新建Spring工程
容器接口与实现类
Bean管理(基于XML)
Bean管理(基于注解)
完全注解开发
AOP
AOP概述
AspectJ实现AOP
AOP的实现步骤---前置通知
其他通知的AOP实现
Spring集成Mybatis
Spring整合Mybatis
Spring事务
Spring事务管理
Spring中使用事务
Spring与Web
在Servlet中使用Spring框架
Spring5新功能
课程导航
计算机基础知识
C
Linux
linux常用软件
计算机网络
程序员修养
设计模式
工具
Git
composer
vim
IntelliJ IDEA
wireshark
laravel
Spring
SpringMVC
Maven
数据库
MySQL
Redis
MongoDB
JDBC
Mybatis
MyBatis-Plus
服务端编程
PHP
Java
shell script
JavaWeb
HTML / CSS
HTML
CSS
HTML5
CSS3
BOOTSTRAP
JavaScript
JavaScript
JQuery
layui
容器接口与实现类
入门---新建Spring工程
 ## 使用maven来构建项目。       ## 修改pom.xml文件,加入相关依赖 目前先只加 ```xml
org.springframework
spring-context
5.2.6.RELEASE
``` ## 创建UserService以及UserServiceImpl类 ```java public interface UserService { void run (); } ``` ```java public class UserServiceImpl implements UserService { @Override public void run() { System.out.println("Hello, I'm running!"); } } ``` ## 创建applicationContext.xml文件  ```xml
``` ## 编写测试 ```java public class TestUserService { @Test public void run () { String resource = "applicationContext.xml"; ApplicationContext context = new ClassPathXmlApplicationContext(resource); UserService userService = (UserService) context.getBean("userService"); userService.run(); } } ```
容器接口与实现类
文章目录