Update samples to the latest Spring Shell and Boot versions

This commit is contained in:
Mahmoud Ben Hassine
2025-02-07 05:21:01 +01:00
parent 45350cbdfb
commit f3d582009e
20 changed files with 124 additions and 143 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.Bootstrap;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -214,8 +214,8 @@ public class Application {
}
// end::snippetE[]
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
package demo.showcase;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import org.springframework.stereotype.Component;
import demo.AbstractStateMachineCommands;
@@ -28,8 +28,8 @@ import reactor.core.publisher.Mono;
@Component
public class StateMachineCommands extends AbstractStateMachineCommands<States, Events> {
@CliCommand(value = "sm event", help = "Sends an event to a state machine")
public String event(@CliOption(key = { "", "event" }, mandatory = true, help = "The event") final Events event) {
@Command(command = "sm event", description = "Sends an event to a state machine")
public String event(@Option(longNames = { "", "event" }, required = true, description = "The event") final Events event) {
getStateMachine()
.sendEvent(Mono.just(MessageBuilder
.withPayload(event).build()))