Refine SpringApplication source types

Update `SpringApplication` so that the `run` methods and constructors
now require `Class<?>` arguments, rather than `Objects`. String based
sources can still be loaded, but must now be set on the `getSources()`
collections. `Package` and `Resource` types are no longer directly
supported.

This change should help IDEs offer better content assist, and will
help integrations with alternative languages such as Ceylon.

Users currently passing in Class references or using the
`spring.main.sources` property should not be affected by this change. If
an XML resource is being used, some refactoring may be required (see the
changes to `SampleSpringXmlApplication` in this commit).

Fixes gh-9170
This commit is contained in:
Phillip Webb
2017-05-15 18:21:34 -07:00
parent 302f038e84
commit 889d43ddc4
12 changed files with 94 additions and 106 deletions

View File

@@ -398,10 +398,10 @@ The `Application.java` file would declare the `main` method, along with the basi
[[using-boot-configuration-classes]]
== Configuration classes
Spring Boot favors Java-based configuration. Although it is possible to call
`SpringApplication.run()` with an XML source, we generally recommend that your primary
source is a `@Configuration` class. Usually the class that defines the `main` method
is also a good candidate as the primary `@Configuration`.
Spring Boot favors Java-based configuration. Although it is possible to use
`SpringApplication` with an XML sources, we generally recommend that your primary
source is a single `@Configuration` class. Usually the class that defines the `main`
method is also a good candidate as the primary `@Configuration`.
TIP: Many Spring configuration examples have been published on the Internet that use XML
configuration. Always try to use the equivalent Java-based configuration if possible.