In its current state, MyApplication.java does not have it's own package and exists in the default package which conflicts with SpringBootApplication. The changes here move the create com.example.myproject package and move MyApplication under it. This also comes with creating a directory structure for the package and moving the code file under it. Also corresponds to issue #34827

Comment From: pivotal-cla

@Rammerhead Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: Rammerhead

@pivotal-cla This is an obvious fix.

Comment From: pivotal-cla

@Rammerhead This Pull Request contains an obvious fix. Signing the Contributor License Agreement is not necessary.

Comment From: snicoll

@Rammerhead unfortunately, I don't think this is an obvious fix so you'll have to sign the CLA if we decide to pursue this.

This PR is moving code back to the guide, which is something we're not keen on doing. If we want to make the package explicit, then we need to expand the tag used in the source code. Unfortunately, the current package is not something we'd use in the guide.

In its current state, MyApplication.java does not have it's own package and exists in the default package

I don't think this is accurate. This is a sample code, not the complete file. It won't compile as it does not include the required imports.

Can we take a step back and can you describe what you're trying to solve?

Comment From: Rammerhead

@snicoll Apologies for my misunderstanding. I was actually looking for a fix on issue #34827 (which pertains to docs.spring.io guide). It isn't mentioned there about the code only being a sample. Though yes, changes in the adoc were probably not what I should've focused on.

Comment From: snicoll

No worries and thanks for following-up.

Comment From: izeye

For your information, https://github.com/spring-projects/spring-boot/issues/34827 seems to be a duplicate of https://github.com/spring-projects/spring-boot/issues/34513, and specifically, the src/main/java/MyApplication.java part in the section seems to be a problem.