spring项目跑起来,只需要spring-context这1个依赖项就行,参考下面:

一、pom.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4 <modelVersion>4.0.0</modelVersion>
5
6 <groupId>com.cnblogs.yjmyzz</groupId>
7 <artifactId>spring-boot-demo</artifactId>
8 <version>0.0.1-SNAPSHOT</version>
9
10 <properties>
11 <java.version>1.8</java.version>
12 </properties>
13
14 <dependencies>
15 <dependency>
16 <groupId>org.springframework</groupId>
17 <artifactId>spring-context</artifactId>
18 <version>5.2.4.RELEASE</version>
19 </dependency>
20 </dependencies>
21
22 <build>
23 <plugins>
24 <plugin>
25 <artifactId>maven-compiler-plugin</artifactId>
26 <version>3.1</version>
27 <configuration>
28 <source>1.8</source>
29 <target>1.8</target>
30 </configuration>
31 </plugin>
32 </plugins>
33 </build>
34
35 </project>

二、示例代码:

 1 package com.cnblogs.yjmyzz.springbootdemo;
2
3 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
4 import org.springframework.context.annotation.ComponentScan;
5 import org.springframework.context.annotation.Configuration;
6 import org.springframework.stereotype.Service;
7
8 /**
9 * @author 菩提树下的杨过
10 */
11 @ComponentScan("com.cnblogs.yjmyzz")
12 @Configuration
13 public class SampleApplication {
14
15 interface SampleService {
16 void helloWorld();
17 }
18
19 @Service
20 class SampleServiceImpl implements SampleService {
21
22 @Override
23 public void helloWorld() {
24 System.out.println("hello spring");
25 }
26 }
27
28 public static void main(String[] args) {
29 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SampleApplication.class);
30 SampleService service = context.getBean(SampleService.class);
31 service.helloWorld();
32 }
33 }

项目结构:

spring-context的依赖关系如下:

spring项目run起来的最小依赖的更多相关文章

  1. Spring IO Platform 解决Spring项目组合中版本依赖

    简介: Spring IO Platform是Spring官网中排第一位的项目.它将Spring的核心API集成到一个适用于现代应用程序的平台中.提供了Spring项目组合中的版本依赖.这些依赖关系是 ...

  2. Maven构建的Spring项目需要哪些依赖?

    Maven构建的Spring项目需要哪些依赖? <!-- Spring依赖 --> <!-- 1.Spring核心依赖 --> <dependency> <g ...

  3. Spring boot - 梳理 - 根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置

    根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置

  4. (转) Spring读书笔记-----部署我的第一个Spring项目

    一.Spring介绍 Spring是一个轻量级的Java EE容器,它也是一种从实际需求出发,着眼于轻便,灵活,易于开发,易测试和易部署的轻量级开发框架.Spring它完成了大量开发中的通用步骤,留给 ...

  5. Spring读书笔记-----部署我的第一个Spring项目

    一.Spring介绍 Spring是一个轻量级的Java EE容器,它也是一种从实际需求出发,着眼于轻便,灵活,易于开发,易测试和易部署的轻量级开发框架.Spring它完成了大量开发中的通用步骤,留给 ...

  6. 使用maven给spring项目打可直接运行的jar包(配置文件内置外置的打法)

    从网上看过许多打jar包的例子,大多是将配置文件打进jar包的.经过本人一番研究,终于搞清楚了怎样将jar包的配置文件外置. 废话不说,直接上spring的pom.xml的配置文件. <proj ...

  7. 详解 Spring 3.0 基于 Annotation 的依赖注入实现(转)

    使用 @Repository.@Service.@Controller 和 @Component 将类标识为 Bean Spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的 ...

  8. Spring实战2:装配bean—依赖注入的本质

    主要内容 Spring的配置方法概览 自动装配bean 基于Java配置文件装配bean 控制bean的创建和销毁 任何一个成功的应用都是由多个为了实现某个业务目标而相互协作的组件构成的,这些组件必须 ...

  9. 详解 Spring 3.0 基于 Annotation 的依赖注入实现--转载

    使用 @Repository.@Service.@Controller 和 @Component 将类标识为 Bean Spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的 ...

  10. Spring Security 3.2.x与Spring 4.0.x的Maven依赖管理

    原文链接: Spring Security with Maven原文日期: 2013年04月24日翻译日期: 2014年06月29日翻译人员: 铁锚 1. 概述 本文通过实例为您介绍怎样使用 Mave ...

随机推荐

  1. windows系统如何开启远程连接

    一.RDP远程桌面介绍 RDP远程桌面即远程桌面系统(Remote Desktop Protocol),是内置于windows系统的网络通信协议.通过RDP,用户可以远程登录到运行windows系统的 ...

  2. termux添加ll命令

    cd ~ vim .bashrc 添加如下内容 alias ll="ls -l" 保存退出 :wq source .bashrc 参考:https://www.cnblogs.co ...

  3. 【HUST】网安|多媒体数据安全实验|LSB隐写和DCT域JSTEG+F4+F5隐写及检测

    文章目录 LSB空域隐写 原理 值对现象原理 实验内容 DCT域隐写 JSteg F4 F5 代码仓库:代码.嵌入提取使用的图像.jpeg_tool库.实验报告_Gitee. 实验环境:MATLAB ...

  4. 网络编程:reactor反应堆_TCP字节流处理和HTTP协议实现

    buffer对象 buffer对象:顾名思义,就是一个缓冲区对象,缓存了从套接字接收来的数据以及需要发往套接字的数据. 如果是从套接字接受来的数据,事件处理回调函数在不断地往buffer对象增加数据, ...

  5. C#中的弱引用

    弱引用保持的是一个GC"不可见"的引用,是指弱引用不会增加对象的引用计数,也不会阻止垃圾回收器对该对象进行回收.因此,弱引用的目标对象可以被垃圾回收器回收,而弱引用本身不会对垃圾回 ...

  6. Friend Circles(dfs)——LeetCode进阶路

    原题链接https://leetcode.com/problems/friend-circles/ 题目描述 There are N students in a class. Some of them ...

  7. 第一次阶段性OOP题目集总结性Blog

    前言: 基础题目训练说明 第一次基础题目有四道,题量适中,考察知识点主要是正则表达式的基本用法,以及简单分类讨论逻辑与java基础语法,考察学生能都否从讨论判断转变到便捷的正则表达式的使用,逻辑上的难 ...

  8. pyqt Qscintilla英文学习笔记

    由于博客园不能上传pdf,所以图片没了,源文件 链接:https://www.123pan.com/s/qdY9-P4fk3 提取码:aRny 通过百度网盘分享的文件:qscintil- 链接:htt ...

  9. AdGuard Home使用体验

    AdGuard Home使用体验 AdGuard Home is a network-wide software for blocking ads and tracking. After you se ...

  10. LLM 输出配置 (LLM output configuration)

    1.概述 大型语言模型(LLM)的输出行为可以通过多种配置参数进行精细控制.这些参数共同决定了模型生成文本的质量.风格和多样性.理解这些配置选项及其相互作用对于有效使用LLM至关重要. 2.输出长度 ...