SpringBoot實(shí)現(xiàn)消息隊(duì)列與異步通信
1 學(xué)習(xí)目標(biāo)與重點(diǎn)提示
學(xué)習(xí)目標(biāo):掌握Spring Boot消息隊(duì)列與異步通信的核心概念與使用方法,包括消息隊(duì)列的定義與特點(diǎn)、Spring Boot與ActiveMQ的集成、Spring Boot與RabbitMQ的集成、Spring Boot與Kafka的集成、Spring Boot異步通信的基本方法、Spring Boot的實(shí)際應(yīng)用場景,學(xué)會(huì)在實(shí)際開發(fā)中處理消息隊(duì)列與異步通信問題。
重點(diǎn):消息隊(duì)列的定義與特點(diǎn)、Spring Boot與ActiveMQ的集成、Spring Boot與RabbitMQ的集成、Spring Boot與Kafka的集成、Spring Boot異步通信的基本方法、Spring Boot的實(shí)際應(yīng)用場景。
2 消息隊(duì)列概述
消息隊(duì)列是Java開發(fā)中的重要組件。
2.1 消息隊(duì)列的定義
定義:消息隊(duì)列是一種異步通信機(jī)制,用于在應(yīng)用程序之間傳遞消息。
作用:
- 實(shí)現(xiàn)應(yīng)用程序之間的異步通信。
- 實(shí)現(xiàn)應(yīng)用程序之間的解耦。
- 提高應(yīng)用程序的性能。
常見的消息隊(duì)列:
- ActiveMQ:Apache ActiveMQ是一款開源的消息隊(duì)列。
- RabbitMQ:RabbitMQ是一款開源的消息隊(duì)列。
- Kafka:Apache Kafka是一款開源的消息隊(duì)列。
? 結(jié)論:消息隊(duì)列是一種異步通信機(jī)制,作用是實(shí)現(xiàn)應(yīng)用程序之間的異步通信、解耦、提高應(yīng)用程序的性能。
2.2 消息隊(duì)列的特點(diǎn)
定義:消息隊(duì)列的特點(diǎn)是指消息隊(duì)列的特性。
特點(diǎn):
- 異步通信:消息發(fā)送者不需要等待消息接收者的響應(yīng)。
- 解耦:消息發(fā)送者與消息接收者之間不需要直接通信。
- 可靠性:消息隊(duì)列提供消息的可靠傳輸。
- 可擴(kuò)展性:消息隊(duì)列可以擴(kuò)展到多個(gè)應(yīng)用程序之間的通信。
? 結(jié)論:消息隊(duì)列的特點(diǎn)包括異步通信、解耦、可靠性、可擴(kuò)展性。
3 Spring Boot與ActiveMQ的集成
Spring Boot與ActiveMQ的集成是Java開發(fā)中的重要內(nèi)容。
3.1 集成ActiveMQ的步驟
定義:集成ActiveMQ的步驟是指使用Spring Boot與ActiveMQ集成的方法。
步驟:
- 創(chuàng)建Spring Boot項(xiàng)目。
- 添加所需的依賴。
- 配置ActiveMQ。
- 創(chuàng)建消息生產(chǎn)者。
- 創(chuàng)建消息消費(fèi)者。
- 測試應(yīng)用。
示例:
pom.xml文件中的依賴:
<dependencies>
<!-- Web依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- ActiveMQ依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<!-- 測試依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
application.properties文件中的ActiveMQ配置:
# 服務(wù)器端口 server.port=8080 # ActiveMQ配置 spring.activemq.broker-url=tcp://localhost:61616 spring.activemq.user=admin spring.activemq.password=admin
消息生產(chǎn)者:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;
@Component
public class MessageProducer {
@Autowired
private JmsTemplate jmsTemplate;
public void sendMessage(String destination, String message) {
jmsTemplate.convertAndSend(destination, message);
System.out.println("發(fā)送消息:" + message);
}
}
消息消費(fèi)者:
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
@Component
public class MessageConsumer {
@JmsListener(destination = "test-queue")
public void receiveMessage(String message) {
System.out.println("接收消息:" + message);
}
}
控制器類:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MessageController {
@Autowired
private MessageProducer messageProducer;
@GetMapping("/send")
public String sendMessage(@RequestParam String message) {
messageProducer.sendMessage("test-queue", message);
return "消息發(fā)送成功";
}
}
測試類:
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ActiveMQApplicationTests {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void contextLoads() {
}
@Test
void testSendMessage() {
String message = "Hello, ActiveMQ!";
String response = restTemplate.getForObject("http://localhost:" + port + "/send?message=" + message, String.class);
assertThat(response).contains("消息發(fā)送成功");
}
}
? 結(jié)論:集成ActiveMQ的步驟包括創(chuàng)建Spring Boot項(xiàng)目、添加所需的依賴、配置ActiveMQ、創(chuàng)建消息生產(chǎn)者、創(chuàng)建消息消費(fèi)者、測試應(yīng)用。
4 Spring Boot與RabbitMQ的集成
Spring Boot與RabbitMQ的集成是Java開發(fā)中的重要內(nèi)容。
4.1 集成RabbitMQ的步驟
定義:集成RabbitMQ的步驟是指使用Spring Boot與RabbitMQ集成的方法。
步驟:
- 創(chuàng)建Spring Boot項(xiàng)目。
- 添加所需的依賴。
- 配置RabbitMQ。
- 創(chuàng)建消息生產(chǎn)者。
- 創(chuàng)建消息消費(fèi)者。
- 測試應(yīng)用。
示例:
pom.xml文件中的依賴:
<dependencies>
<!-- Web依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- RabbitMQ依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- 測試依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
application.properties文件中的RabbitMQ配置:
# 服務(wù)器端口 server.port=8080 # RabbitMQ配置 spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 spring.rabbitmq.username=guest spring.rabbitmq.password=guest
消息生產(chǎn)者:
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class MessageProducer {
@Autowired
private RabbitTemplate rabbitTemplate;
public void sendMessage(String exchange, String routingKey, String message) {
rabbitTemplate.convertAndSend(exchange, routingKey, message);
System.out.println("發(fā)送消息:" + message);
}
}
消息消費(fèi)者:
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
@Component
public class MessageConsumer {
@RabbitListener(queues = "test-queue")
public void receiveMessage(String message) {
System.out.println("接收消息:" + message);
}
}
RabbitMQ配置類:
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitMQConfig {
@Bean
public Queue testQueue() {
return new Queue("test-queue", true);
}
@Bean
public DirectExchange testExchange() {
return new DirectExchange("test-exchange");
}
@Bean
public Binding testBinding() {
return BindingBuilder.bind(testQueue()).to(testExchange()).with("test-routing-key");
}
}
控制器類:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MessageController {
@Autowired
private MessageProducer messageProducer;
@GetMapping("/send")
public String sendMessage(@RequestParam String message) {
messageProducer.sendMessage("test-exchange", "test-routing-key", message);
return "消息發(fā)送成功";
}
}
測試類:
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class RabbitMQApplicationTests {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void contextLoads() {
}
@Test
void testSendMessage() {
String message = "Hello, RabbitMQ!";
String response = restTemplate.getForObject("http://localhost:" + port + "/send?message=" + message, String.class);
assertThat(response).contains("消息發(fā)送成功");
}
}
? 結(jié)論:集成RabbitMQ的步驟包括創(chuàng)建Spring Boot項(xiàng)目、添加所需的依賴、配置RabbitMQ、創(chuàng)建消息生產(chǎn)者、創(chuàng)建消息消費(fèi)者、測試應(yīng)用。
5 Spring Boot與Kafka的集成
Spring Boot與Kafka的集成是Java開發(fā)中的重要內(nèi)容。
5.1 集成Kafka的步驟
定義:集成Kafka的步驟是指使用Spring Boot與Kafka集成的方法。
步驟:
- 創(chuàng)建Spring Boot項(xiàng)目。
- 添加所需的依賴。
- 配置Kafka。
- 創(chuàng)建消息生產(chǎn)者。
- 創(chuàng)建消息消費(fèi)者。
- 測試應(yīng)用。
示例:
pom.xml文件中的依賴:
<dependencies>
<!-- Web依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Kafka依賴 -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- 測試依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
application.properties文件中的Kafka配置:
# 服務(wù)器端口 server.port=8080 # Kafka配置 spring.kafka.bootstrap-servers=localhost:9092 spring.kafka.consumer.group-id=test-group spring.kafka.consumer.auto-offset-reset=earliest spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
消息生產(chǎn)者:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;
@Component
public class MessageProducer {
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
public void sendMessage(String topic, String message) {
kafkaTemplate.send(topic, message);
System.out.println("發(fā)送消息:" + message);
}
}
消息消費(fèi)者:
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
@Component
public class MessageConsumer {
@KafkaListener(topics = "test-topic", groupId = "test-group")
public void receiveMessage(String message) {
System.out.println("接收消息:" + message);
}
}
控制器類:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MessageController {
@Autowired
private MessageProducer messageProducer;
@GetMapping("/send")
public String sendMessage(@RequestParam String message) {
messageProducer.sendMessage("test-topic", message);
return "消息發(fā)送成功";
}
}
測試類:
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class KafkaApplicationTests {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void contextLoads() {
}
@Test
void testSendMessage() {
String message = "Hello, Kafka!";
String response = restTemplate.getForObject("http://localhost:" + port + "/send?message=" + message, String.class);
assertThat(response).contains("消息發(fā)送成功");
}
}
? 結(jié)論:集成Kafka的步驟包括創(chuàng)建Spring Boot項(xiàng)目、添加所需的依賴、配置Kafka、創(chuàng)建消息生產(chǎn)者、創(chuàng)建消息消費(fèi)者、測試應(yīng)用。
6 Spring Boot異步通信的基本方法
Spring Boot異步通信的基本方法包括使用@Async注解、使用CompletableFuture、使用消息隊(duì)列。
6.1 使用@Async注解
定義:使用@Async注解是指使用Spring Boot異步通信的基本方法之一。
作用:
- 實(shí)現(xiàn)異步通信。
- 提高應(yīng)用程序的性能。
示例:
pom.xml文件中的依賴:
<dependencies>
<!-- Web依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 測試依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
異步配置類:
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
@Configuration
@EnableAsync
public class AsyncConfig {
}
異步服務(wù)類:
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@Service
public class AsyncService {
@Async
public void asyncMethod() {
System.out.println("異步方法執(zhí)行:" + Thread.currentThread().getName());
}
}
控制器類:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class AsyncController {
@Autowired
private AsyncService asyncService;
@GetMapping("/async")
public String asyncMethod() {
System.out.println("主線程執(zhí)行:" + Thread.currentThread().getName());
asyncService.asyncMethod();
return "異步方法調(diào)用成功";
}
}
測試類:
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class AsyncApplicationTests {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void contextLoads() {
}
@Test
void testAsyncMethod() {
String response = restTemplate.getForObject("http://localhost:" + port + "/async", String.class);
assertThat(response).contains("異步方法調(diào)用成功");
}
}
? 結(jié)論:使用@Async注解是指使用Spring Boot異步通信的基本方法之一,作用是實(shí)現(xiàn)異步通信、提高應(yīng)用程序的性能。
6.2 使用CompletableFuture
定義:使用CompletableFuture是指使用Spring Boot異步通信的基本方法之一。
作用:
- 實(shí)現(xiàn)異步通信。
- 提高應(yīng)用程序的性能。
示例:
控制器類:
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@RestController
public class CompletableFutureController {
@GetMapping("/completableFuture")
public String completableFuture() throws ExecutionException, InterruptedException {
System.out.println("主線程執(zhí)行:" + Thread.currentThread().getName());
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
System.out.println("異步方法執(zhí)行:" + Thread.currentThread().getName());
});
future.get();
return "CompletableFuture調(diào)用成功";
}
}
測試類:
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class CompletableFutureApplicationTests {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void contextLoads() {
}
@Test
void testCompletableFuture() {
String response = restTemplate.getForObject("http://localhost:" + port + "/completableFuture", String.class);
assertThat(response).contains("CompletableFuture調(diào)用成功");
}
}
? 結(jié)論:使用CompletableFuture是指使用Spring Boot異步通信的基本方法之一,作用是實(shí)現(xiàn)異步通信、提高應(yīng)用程序的性能。
7 Spring Boot的實(shí)際應(yīng)用場景
在實(shí)際開發(fā)中,Spring Boot消息隊(duì)列與異步通信的應(yīng)用場景非常廣泛,如:
- 實(shí)現(xiàn)用戶注冊的異步處理。
- 實(shí)現(xiàn)訂單的異步處理。
- 實(shí)現(xiàn)郵件發(fā)送的異步處理。
- 實(shí)現(xiàn)日志的異步處理。
示例:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@EnableAsync
public class UserRegistrationApplication {
public static void main(String[] args) {
SpringApplication.run(UserRegistrationApplication.class, args);
}
}
@Service
class UserRegistrationService {
@Async
public void sendWelcomeEmail(String email) {
System.out.println("發(fā)送歡迎郵件:" + email);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("郵件發(fā)送成功:" + email);
}
}
@RestController
class UserRegistrationController {
@Autowired
private UserRegistrationService userRegistrationService;
@GetMapping("/register")
public String registerUser(String email) {
System.out.println("用戶注冊:" + email);
userRegistrationService.sendWelcomeEmail(email);
return "用戶注冊成功";
}
}
// 測試類
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class UserRegistrationApplicationTests {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void contextLoads() {
}
@Test
void testRegisterUser() {
String email = "test@example.com";
String response = restTemplate.getForObject("http://localhost:" + port + "/register?email=" + email, String.class);
assertThat(response).contains("用戶注冊成功");
}
}
輸出結(jié)果:
訪問http://localhost:8080/register?email=test@example.com:返回用戶注冊成功。
控制臺(tái)輸出:
用戶注冊:test@example.com
發(fā)送歡迎郵件:test@example.com
郵件發(fā)送成功:test@example.com
? 結(jié)論:在實(shí)際開發(fā)中,Spring Boot消息隊(duì)列與異步通信的應(yīng)用場景非常廣泛,需要根據(jù)實(shí)際問題選擇合適的異步通信方法。
總結(jié)
本章我們學(xué)習(xí)了Spring Boot消息隊(duì)列與異步通信,包括消息隊(duì)列的定義與特點(diǎn)、Spring Boot與ActiveMQ的集成、Spring Boot與RabbitMQ的集成、Spring Boot與Kafka的集成、Spring Boot異步通信的基本方法、Spring Boot的實(shí)際應(yīng)用場景,學(xué)會(huì)了在實(shí)際開發(fā)中處理消息隊(duì)列與異步通信問題。其中,消息隊(duì)列的定義與特點(diǎn)、Spring Boot與ActiveMQ的集成、Spring Boot與RabbitMQ的集成、Spring Boot與Kafka的集成、Spring Boot異步通信的基本方法、Spring Boot的實(shí)際應(yīng)用場景是本章的重點(diǎn)內(nèi)容。從下一章開始,我們將學(xué)習(xí)Spring Boot的其他組件、微服務(wù)等內(nèi)容。
到此這篇關(guān)于SpringBoot實(shí)現(xiàn)消息隊(duì)列與異步通信的文章就介紹到這了,更多相關(guān)SpringBoot 消息隊(duì)列與異步通信內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringBoot集成SwaggerUi以及啟動(dòng)時(shí)遇到的錯(cuò)誤
這篇文章主要介紹了SpringBoot集成SwaggerUi以及啟動(dòng)時(shí)遇到的錯(cuò)誤,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
springboot @Configuration和@Componment的區(qū)別及說明
這篇文章主要介紹了springboot @Configuration和@Componment的區(qū)別及說明,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-06-06
深入了解Java核心類庫--BigDecimal和System類
這篇文章主要為大家詳細(xì)介紹了javaBigDecimal和System類定義與使用的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能給你帶來幫助2021-07-07
淺談Mybatis中resultType為hashmap的情況
這篇文章主要介紹了淺談Mybatis中resultType為hashmap的情況,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-12-12
Java實(shí)現(xiàn)時(shí)間與字符串互相轉(zhuǎn)換詳解
這篇文章主要為大家詳細(xì)介紹了Java中實(shí)現(xiàn)時(shí)間與字符串互相轉(zhuǎn)換的相關(guān)方法,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2025-04-04
springboot @ConditionalOnMissingBean注解的作用詳解
這篇文章主要介紹了springboot @ConditionalOnMissingBean注解的作用詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08
spring boot 如何指定profile啟動(dòng)
這篇文章主要介紹了spring boot 如何指定profile啟動(dòng)的操作,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07

