From 32c65f2da739e740d928c48952227cc25dcb8da3 Mon Sep 17 00:00:00 2001 From: Eric Bottard Date: Wed, 4 Oct 2017 11:15:01 +0200 Subject: [PATCH] Allow usage without Spring Boot AutoConfiguration Fixes #166 --- .../jline/JLineShellAutoConfiguration.java | 4 +- .../shell/samples/noautoconf/NoAutoConf.java | 69 +++++++++++++++++++ spring-shell-starter/pom.xml | 1 - 3 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java diff --git a/spring-shell-core/src/main/java/org/springframework/shell/jline/JLineShellAutoConfiguration.java b/spring-shell-core/src/main/java/org/springframework/shell/jline/JLineShellAutoConfiguration.java index ae9ebe0d..2617ac55 100644 --- a/spring-shell-core/src/main/java/org/springframework/shell/jline/JLineShellAutoConfiguration.java +++ b/spring-shell-core/src/main/java/org/springframework/shell/jline/JLineShellAutoConfiguration.java @@ -61,12 +61,12 @@ import org.springframework.shell.Shell; * @author Florent Biville */ @Configuration -class JLineShellAutoConfiguration { +public class JLineShellAutoConfiguration { @Autowired private PromptProvider promptProvider; - @Autowired + @Autowired @Lazy private History history; @Autowired diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java new file mode 100644 index 00000000..14a26353 --- /dev/null +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java @@ -0,0 +1,69 @@ +/* + * Copyright 2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.shell.samples.noautoconf; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.shell.SpringShellAutoConfiguration; +import org.springframework.shell.jcommander.JCommanderParameterResolverAutoConfiguration; +import org.springframework.shell.jline.JLineShellAutoConfiguration; +import org.springframework.shell.legacy.LegacyAdapterAutoConfiguration; +import org.springframework.shell.samples.jcommander.JCommanderCommands; +import org.springframework.shell.samples.legacy.LegacyCommands; +import org.springframework.shell.samples.standard.Commands; +import org.springframework.shell.samples.standard.DynamicCommands; +import org.springframework.shell.samples.standard.TableCommands; +import org.springframework.shell.standard.FileValueProvider; +import org.springframework.shell.standard.StandardAPIAutoConfiguration; +import org.springframework.shell.standard.commands.StandardCommandsAutoConfiguration; + +/** + * This class shows how to use the full extent of Spring Shell without relying on Boot auto configuration. + * + * @author Eric Bottard + */ +@Configuration +@Import({ + // Core runtime + SpringShellAutoConfiguration.class, + JLineShellAutoConfiguration.class, + // Various Resolvers + JCommanderParameterResolverAutoConfiguration.class, + LegacyAdapterAutoConfiguration.class, + StandardAPIAutoConfiguration.class, + // Built-In Commands + StandardCommandsAutoConfiguration.class, + // Allows ${} supports + PropertyPlaceholderAutoConfiguration.class, + // Sample Commands + JCommanderCommands.class, + LegacyCommands.class, + Commands.class, + FileValueProvider.class, + DynamicCommands.class, + TableCommands.class, + }) +public class NoAutoConf { + + public static void main(String[] args) { + ConfigurableApplicationContext context = SpringApplication.run(NoAutoConf.class, args); + } + +} diff --git a/spring-shell-starter/pom.xml b/spring-shell-starter/pom.xml index fc3d84a1..9d875a4c 100644 --- a/spring-shell-starter/pom.xml +++ b/spring-shell-starter/pom.xml @@ -26,7 +26,6 @@ org.springframework.shell spring-shell-standard-commands - runtime org.springframework.shell