@groovy.transform.CompileStatic class GrailsApplicationContextCommandRunner extends DevelopmentGrailsApplication
| Type | Name and description |
|---|---|
java.lang.String |
commandName |
| Properties inherited from class | Properties |
|---|---|
class GrailsApp |
configuredEnvironment, developmentModeActive, enableBeanCreationProfiler |
| Constructor and description |
|---|
protected GrailsApplicationContextCommandRunner(java.lang.String commandName, java.lang.Class<?>[] sources) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.lang.String[] |
filterCommandOptions(java.lang.String[] args)Filters out command-specific options (arguments starting with '--') from the args array before they are passed to Spring Boot's SpringApplication.run(). |
|
static void |
main(java.lang.String[] args)Main method to run an existing Application class |
|
static java.lang.Object |
resolveAutowireTarget(java.lang.Object command)Resolves the object that Spring should autowire and inspect for the skipBootstrap
property. |
|
static java.lang.Boolean |
resolveSkipBootstrap(java.lang.Object command)Reads the optional skipBootstrap flag declared by a command. |
|
ConfigurableApplicationContext |
run(java.lang.String[] args) |
|
static java.lang.String |
unknownCommandMessage(java.lang.String commandName, java.lang.String missingCommandHint) |
| Methods inherited from class | Name |
|---|---|
class DevelopmentGrailsApplication |
configureApplicationContextClass |
class GrailsApp |
compileGroovyFile, configureCliPidFileWriter, configureDirectoryWatcher, configureEnvironment, createApplicationContext, createPluginManagerListener, enableDevelopmentModeWatch, isDevelopmentModeActive, postProcessApplicationContext, printRunStatus, recompile, run, run, run, setDevelopmentModeActive |
Filters out command-specific options (arguments starting with '--') from the
args array before they are passed to Spring Boot's SpringApplication.run().
Spring Boot interprets --key=value arguments as property overrides via
CommandLinePropertySource. When Grails command options like
--dataSource=analytics are passed through, Spring Boot sets
dataSource=analytics as a top-level property, corrupting GORM's datasource
configuration which expects dataSource to be a Map containing url, username, etc.
Command options are still available to the Grails command via
CommandLineParser.parse(args) which receives the unfiltered args.
args - the full argument array including command optionsMain method to run an existing Application class
args - The first argument is the Command name, the last argument is the Application class name Resolves the object that Spring should autowire and inspect for the skipBootstrap
property. For a command loaded through the deprecated Grails 7 compatibility layer the
registry returns an ApplicationCommandTargetAware adapter; the target it wraps - not
the adapter - is what must be autowired and queried, because the adapter forwards
applicationContext and handle to that same instance. Any other command is
returned unchanged.
command - the command resolved from the registrycommand is ApplicationCommandTargetAware, otherwise command Reads the optional skipBootstrap flag declared by a command. The flag is looked up on
the autowire target rather than on command itself, so a command reached through the
deprecated Grails 7 compatibility layer keeps its flag: the adapter forwards handle
but not the arbitrary properties a command declares.
command - the command resolved from the registrynull when the target declares no skipBootstrap property or declares one that is not a java.lang.Boolean