spring项目run起来的最小依赖
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起来的最小依赖的更多相关文章
- Spring IO Platform 解决Spring项目组合中版本依赖
简介: Spring IO Platform是Spring官网中排第一位的项目.它将Spring的核心API集成到一个适用于现代应用程序的平台中.提供了Spring项目组合中的版本依赖.这些依赖关系是 ...
- Maven构建的Spring项目需要哪些依赖?
Maven构建的Spring项目需要哪些依赖? <!-- Spring依赖 --> <!-- 1.Spring核心依赖 --> <dependency> <g ...
- Spring boot - 梳理 - 根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置
根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置
- (转) Spring读书笔记-----部署我的第一个Spring项目
一.Spring介绍 Spring是一个轻量级的Java EE容器,它也是一种从实际需求出发,着眼于轻便,灵活,易于开发,易测试和易部署的轻量级开发框架.Spring它完成了大量开发中的通用步骤,留给 ...
- Spring读书笔记-----部署我的第一个Spring项目
一.Spring介绍 Spring是一个轻量级的Java EE容器,它也是一种从实际需求出发,着眼于轻便,灵活,易于开发,易测试和易部署的轻量级开发框架.Spring它完成了大量开发中的通用步骤,留给 ...
- 使用maven给spring项目打可直接运行的jar包(配置文件内置外置的打法)
从网上看过许多打jar包的例子,大多是将配置文件打进jar包的.经过本人一番研究,终于搞清楚了怎样将jar包的配置文件外置. 废话不说,直接上spring的pom.xml的配置文件. <proj ...
- 详解 Spring 3.0 基于 Annotation 的依赖注入实现(转)
使用 @Repository.@Service.@Controller 和 @Component 将类标识为 Bean Spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的 ...
- Spring实战2:装配bean—依赖注入的本质
主要内容 Spring的配置方法概览 自动装配bean 基于Java配置文件装配bean 控制bean的创建和销毁 任何一个成功的应用都是由多个为了实现某个业务目标而相互协作的组件构成的,这些组件必须 ...
- 详解 Spring 3.0 基于 Annotation 的依赖注入实现--转载
使用 @Repository.@Service.@Controller 和 @Component 将类标识为 Bean Spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的 ...
- Spring Security 3.2.x与Spring 4.0.x的Maven依赖管理
原文链接: Spring Security with Maven原文日期: 2013年04月24日翻译日期: 2014年06月29日翻译人员: 铁锚 1. 概述 本文通过实例为您介绍怎样使用 Mave ...
随机推荐
- Python 类不要再写 __init__ 方法了
花下猫语:我们周刊第 98 期分享过一篇文章,它指出了 __init__ 方法存在的问题和新的最佳实践,第 99 期也分享了一篇文章佐证了第一篇文章的观点.我认为它们提出的是一个值得注意和思考的问题, ...
- 代码随想录第十七天 | Leecode 654. 最大二叉树、617. 合并二叉树、700. 二叉搜索树中的搜索、98. 验证二叉搜索树
Leecode 654. 最大二叉树 题目描述 给定一个不重复的整数数组 nums . 最大二叉树 可以用下面的算法从 nums 递归地构建: 创建一个根节点,其值为 nums 中的最大值. 递归地在 ...
- Spring Boot Jpa封装快速构建Specification、OrderBy、Pageable的查询条件
1.简介 在我们使用JPA时,构建 Specification 查询条件时重复代码过多,而且需要大量的无效代码. 2.工具类提供的方法 2.1.自动构建规范 /** * 自动构建规范 * * @p ...
- P11071 「QMSOI R1」 Distorted Fate题解
题意: 给定一个序列,给定两种操作: 将一个区间异或上一个给定的值. 给定 \(l,r\) 求 \[{\large (\sum_{i=l}^r\bigcup_{j=l}^i A_j) \bmod 2^ ...
- VitePress 集成 Twikoo 评论
Twikoo 是一个简洁.安全.免费的静态网站评论系统. 主要特点:免费搭建,部署简单,功能很完善,隐私护安全,通知发邮件,管理有内嵌,总之免费又方便 关于后端部署,大家可以看官网,或者这篇 Vite ...
- Python标准库学习之logging
前言 在python程序中,出于调试监测或者追踪(track)的目的,一般会在关键的部位加print语句来输出监测的变量值,但对于复杂的程序来讲,这样的调试手段就远远不够了,这也是logging库存在 ...
- Seata源码—7.Seata TCC模式的事务处理
大纲 1.Seata TCC分布式事务案例配置 2.Seata TCC案例服务提供者启动分析 3.@TwoPhaseBusinessAction注解扫描源码 4.Seata TCC案例分布式事务入口分 ...
- String to Integer (atoi)——LeetCode进阶路⑧
原题链接https://leetcode.com/problems/string-to-integer-atoi/ 说实话,看到这道题之前,看这通过率有点慌,到底是因为啥 让一道medium的题目这么 ...
- 使用Files.walk删除文件
摘要:使用Files.walk删除指定文件名的文件. 使用Files.walk工具,递归判断指定目录中的常规文件路径名是否符合约定名称,如果满足条件就删除. public class DelFil ...
- GC-QA-RAG 智能问答系统的文档切片
本章节介绍 GC-QA-RAG 智能问答系统的文档切片原理,即如何将原始文档的知识点切片后存入向量数据库. 1. 原始思路 将整个文档作为输入,交由大语言模型自动生成问答对(QA Pairs),以支持 ...