У меня есть следующий build.gradle:
Код: Выделить всё
plugins {
id 'java'
id 'org.springframework.boot' version '4.0.1'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
description = 'Demo project for Spring Boot'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-artemis'
testImplementation 'org.springframework.boot:spring-boot-starter-artemis-test'
implementation 'org.apache.activemq:artemis-jms-server'
}
tasks.named('test') {
useJUnitPlatform()
}
Код: Выделить всё
spring:
main:
banner-mode: off
artemis:
mode: embedded # server mode
embedded:
enabled: true
host: localhost
port: 61234
Код: Выделить всё
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MainApp {
public static void main(String[] args) {
SpringApplication.run(MainApp.class, args);
}
}
Код: Выделить всё
package com.example.demo.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.artemis.autoconfigure.ArtemisConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ArtemisConfig {
@Value("${spring.artemis.host:localhost}")
private String host;
@Value("${spring.artemis.port:61616}")
private int port;
@Bean
public ArtemisConfigurationCustomizer myCustomizer() {
return configuration -> {
final String uri = "tcp://" + host + ":" + port;
try {
configuration.addAcceptorConfiguration("netty", uri);
} catch (Exception e) {
}
};
}
}
Код: Выделить всё
2025-12-25T19:55:04.896Z INFO 12836 --- [ main] com.example.demo.MainApp : Starting MainApp using Java 21.0.1 with PID 12836 (D:\Development\spring-artemis\build\classes\java\main started by ctb in D:\Development\spring-artemis)
2025-12-25T19:55:04.899Z INFO 12836 --- [ main] com.example.demo.MainApp : No active profile set, falling back to 1 default profile: "default"
2025-12-25T19:55:05.436Z INFO 12836 --- [ main] com.example.demo.MainApp : Started MainApp in 1.016 seconds (process running for 1.415)
Может ли кто-нибудь помочь?
Подробнее здесь: https://stackoverflow.com/questions/798 ... pring-boot
Мобильная версия