Spring項(xiàng)目運(yùn)行依賴spring-contex解析
spring項(xiàng)目跑起來,只需要spring-context這1個(gè)依賴項(xiàng)就行,參考下面:
一、pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.cnblogs.yjmyzz</groupId> <artifactId>spring-boot-demo</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.4.RELEASE</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
二、示例代碼:
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(); } }
項(xiàng)目結(jié)構(gòu):
spring-context的依賴關(guān)系如下:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Java之通過OutputStream寫入文件與文件復(fù)制問題
這篇文章主要介紹了Java之通過OutputStream寫入文件與文件復(fù)制問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04Java 內(nèi)省introspector相關(guān)原理代碼解析
這篇文章主要介紹了Java 內(nèi)省introspector相關(guān)原理代碼解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07關(guān)于@RequestBody和@RequestParam注解的使用詳解
這篇文章主要介紹了關(guān)于@RequestBody和@RequestParam注解的使用詳解,本文十分具有參考意義,希望可以幫助到你,如果有錯(cuò)誤的地方還望不吝賜教2023-03-03java實(shí)現(xiàn)稀疏矩陣的壓縮與解壓的方法
這篇文章主要介紹了java實(shí)現(xiàn)稀疏矩陣的壓縮與解壓 ,把該稀疏矩陣壓縮以三元組形式表示并以文件形式保存,再寫另一個(gè)程序讀取文件中的信息把壓縮后的三元組還原成原來的稀疏矩陣,需要的朋友可以參考下2022-03-03Springboot+Jackson自定義注解數(shù)據(jù)脫敏的項(xiàng)目實(shí)踐
數(shù)據(jù)脫敏可以對(duì)敏感數(shù)據(jù)比如 手機(jī)號(hào)、銀行卡號(hào)等信息進(jìn)行轉(zhuǎn)換或者修改,本文主要介紹了Springboot+Jackson?自定義注解數(shù)據(jù)脫敏,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08Java實(shí)現(xiàn)自定義LinkedList類的示例代碼
LinkedList類跟ArrayList類不同,它通過指針以及結(jié)點(diǎn)的操作對(duì)鏈表進(jìn)行增刪改查。本文就來和大家分享下Java如何為實(shí)現(xiàn)自定義LinkedList類,需要的可以參考一下2022-08-08Java中將UUID存儲(chǔ)為Base64字符串的方法實(shí)現(xiàn)
使用Base64編碼來對(duì)UUID存儲(chǔ)在一些特定的場(chǎng)合被廣泛的使用,本文主要介紹了Java中將UUID存儲(chǔ)為Base64字符串的方法實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下2024-04-04