spring项目跑起来,只需要spring-context这1个依赖项就行,参考下面:
一、pom.xml
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://.cnblogs.yjmyzz")@Configurationpublic class SampleApplication { interface SampleService { void helloWorld(); } @Service class SampleServiceImpl implements SampleService { @Override public void helloWorld() { System.out.println("hello spring"); } } public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleApplication.class); SampleService service = context.getBean(SampleService.class); service.helloWorld(); }}项目结构:
spring-context的依赖关系如下:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。