spring項目跑起來,只需要spring-context這1個依賴項就行,參考下面:
一、pom.xml
4.0.0com.cnblogs.yjmyzzspring-boot-demo0.0.1-SNAPSHOT1.8org.springframeworkspring-context5.2.4.RELEASEmaven-compiler-plugin3.11.81.8
二、示例代碼:
package com.cnblogs.yjmyzz.springbootdemo; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Service; /** * @author 菩提樹下的楊過 */ @ComponentScan("com.cnblogs.yjmyzz") @Configuration public 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的依賴關係如下:
[月球人 ] Spring項目運行依賴spring-contex解析已經有253次圍觀