Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish #770

Merged
merged 1 commit into from
Jul 20, 2019
Merged

Polish #770

merged 1 commit into from
Jul 20, 2019

Conversation

snicoll
Copy link
Contributor

@snicoll snicoll commented Jul 20, 2019

Rather that defining the 3 annotations to enable configuration, auto-configuration and component scan, we use @SpringBootApplication.

We don't recommend using field injections and we prefer if the SpringApplication is as simple as possible as it is the root of the context. This PR moves the logic of executing the command in a separate class.

@codecov-io
Copy link

codecov-io commented Jul 20, 2019

Codecov Report

Merging #770 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #770   +/-   ##
=========================================
  Coverage     93.15%   93.15%           
  Complexity      385      385           
=========================================
  Files             2        2           
  Lines          5684     5684           
  Branches       1480     1480           
=========================================
  Hits           5295     5295           
  Misses          186      186           
  Partials        203      203

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ae4b57...6728432. Read the comment docs.

@remkop remkop added this to the 4.0.1 milestone Jul 20, 2019
@remkop remkop merged commit 12008cd into remkop:master Jul 20, 2019
@remkop
Copy link
Owner

remkop commented Jul 20, 2019

@snicoll Thanks for improving the example!
Question: How will the SpringApplication.run method know to invoke the MyApplicationRunner.run method, since the MyApplication class has no reference to MyApplicationRunner? Does it scan the classpath for classes implementing CommandLineRunner?

@snicoll
Copy link
Contributor Author

snicoll commented Jul 20, 2019

Ah, sorry. No Spring doesn't scan the classpath unless told to. Adding @SpringBootApplication means that classpath occurs on the package of the app (and all sub-packages) but you need a stereotype to indicate it should be handled as a bean.

I forgot that and submitted #771 to fix it. Thanks for the review

@remkop
Copy link
Owner

remkop commented Jul 20, 2019

I see. Thank you for the clarification!

remkop added a commit that referenced this pull request Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants