Springboot doesn't work except when hello is typed












1















I created a very simply SpringBoot project using my groupId and artifactId. Looks like it doesn't want to kick off and some mappings are missing. But when I use the same package names and classnames as the SPring Boot tutorial which is on spring.io site, it works.



My POM is the following:



<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.spring</groupId>
<artifactId>firstspringboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<url>http://maven.apache.org</url>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.0.3.RELEASE</version>

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

</dependencies>




My Resource 'Greeting'



package com.my.spring.firstspringboot.entities;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class Greeting {

private String id;
private String firstName;
private String lastName;

public Greeting() {

}
public Greeting(String firstName, String lastName) throws NoSuchAlgorithmException {
this.setFirstName(firstName);
this.setLastName(lastName);
this.setId(new StringBuilder().append(SecureRandom.getInstance("SHA1PRNG").nextInt()).append("_").append(System.currentTimeMillis()).toString());
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

@Override
public String toString() {
return new StringBuilder().append("{n"name":"").append(this.firstName).append(" ").append(this.lastName).append(""n").append(",").append("{n"id":"").append(this.id).append(""").toString();
}
}


And its Controller:



package com.my.spring.firstspringboot.controllers;

import java.security.NoSuchAlgorithmException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.my.spring.firstspringboot.entities.Greeting;

@RestController
public class GreetingController {

@RequestMapping("/")
public String home() {
return "Welcome!";
}

@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(name="name",defaultValue="John") String name) throws NoSuchAlgorithmException {
return new Greeting(name,name);
}

}


And main App



package com.my.spring.firstspringboot.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App

{

public static void main(String args)

{

SpringApplication.run(App.class, args);

}

}


Is there something more that I need to do here? I thought it's simply a boot and autoconfigure by default.










share|improve this question

























  • Please provide the error message

    – Chirdeep Tomar
    Nov 12 '18 at 18:52











  • @ChirdeepTomar It's a 404 not found. It doesn't even hit the controller class.

    – ha9u63ar
    Nov 12 '18 at 19:06













  • Change RequestMapping to GetMapping

    – Chirdeep Tomar
    Nov 12 '18 at 19:09






  • 1





    Put your Application class in the package com.my.spring.firstspringboot. docs.spring.io/spring-boot/docs/current/reference/htmlsingle/…

    – JB Nizet
    Nov 12 '18 at 19:50













  • @ChirdeepTomar I don't think that's the issue here. RequestMapping and RequestController have been designed to automatically handle certain web application based configs. I believe this is due to some inconsistence in package or resource lookup

    – ha9u63ar
    Nov 13 '18 at 8:27
















1















I created a very simply SpringBoot project using my groupId and artifactId. Looks like it doesn't want to kick off and some mappings are missing. But when I use the same package names and classnames as the SPring Boot tutorial which is on spring.io site, it works.



My POM is the following:



<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.spring</groupId>
<artifactId>firstspringboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<url>http://maven.apache.org</url>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.0.3.RELEASE</version>

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

</dependencies>




My Resource 'Greeting'



package com.my.spring.firstspringboot.entities;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class Greeting {

private String id;
private String firstName;
private String lastName;

public Greeting() {

}
public Greeting(String firstName, String lastName) throws NoSuchAlgorithmException {
this.setFirstName(firstName);
this.setLastName(lastName);
this.setId(new StringBuilder().append(SecureRandom.getInstance("SHA1PRNG").nextInt()).append("_").append(System.currentTimeMillis()).toString());
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

@Override
public String toString() {
return new StringBuilder().append("{n"name":"").append(this.firstName).append(" ").append(this.lastName).append(""n").append(",").append("{n"id":"").append(this.id).append(""").toString();
}
}


And its Controller:



package com.my.spring.firstspringboot.controllers;

import java.security.NoSuchAlgorithmException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.my.spring.firstspringboot.entities.Greeting;

@RestController
public class GreetingController {

@RequestMapping("/")
public String home() {
return "Welcome!";
}

@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(name="name",defaultValue="John") String name) throws NoSuchAlgorithmException {
return new Greeting(name,name);
}

}


And main App



package com.my.spring.firstspringboot.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App

{

public static void main(String args)

{

SpringApplication.run(App.class, args);

}

}


Is there something more that I need to do here? I thought it's simply a boot and autoconfigure by default.










share|improve this question

























  • Please provide the error message

    – Chirdeep Tomar
    Nov 12 '18 at 18:52











  • @ChirdeepTomar It's a 404 not found. It doesn't even hit the controller class.

    – ha9u63ar
    Nov 12 '18 at 19:06













  • Change RequestMapping to GetMapping

    – Chirdeep Tomar
    Nov 12 '18 at 19:09






  • 1





    Put your Application class in the package com.my.spring.firstspringboot. docs.spring.io/spring-boot/docs/current/reference/htmlsingle/…

    – JB Nizet
    Nov 12 '18 at 19:50













  • @ChirdeepTomar I don't think that's the issue here. RequestMapping and RequestController have been designed to automatically handle certain web application based configs. I believe this is due to some inconsistence in package or resource lookup

    – ha9u63ar
    Nov 13 '18 at 8:27














1












1








1








I created a very simply SpringBoot project using my groupId and artifactId. Looks like it doesn't want to kick off and some mappings are missing. But when I use the same package names and classnames as the SPring Boot tutorial which is on spring.io site, it works.



My POM is the following:



<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.spring</groupId>
<artifactId>firstspringboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<url>http://maven.apache.org</url>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.0.3.RELEASE</version>

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

</dependencies>




My Resource 'Greeting'



package com.my.spring.firstspringboot.entities;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class Greeting {

private String id;
private String firstName;
private String lastName;

public Greeting() {

}
public Greeting(String firstName, String lastName) throws NoSuchAlgorithmException {
this.setFirstName(firstName);
this.setLastName(lastName);
this.setId(new StringBuilder().append(SecureRandom.getInstance("SHA1PRNG").nextInt()).append("_").append(System.currentTimeMillis()).toString());
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

@Override
public String toString() {
return new StringBuilder().append("{n"name":"").append(this.firstName).append(" ").append(this.lastName).append(""n").append(",").append("{n"id":"").append(this.id).append(""").toString();
}
}


And its Controller:



package com.my.spring.firstspringboot.controllers;

import java.security.NoSuchAlgorithmException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.my.spring.firstspringboot.entities.Greeting;

@RestController
public class GreetingController {

@RequestMapping("/")
public String home() {
return "Welcome!";
}

@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(name="name",defaultValue="John") String name) throws NoSuchAlgorithmException {
return new Greeting(name,name);
}

}


And main App



package com.my.spring.firstspringboot.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App

{

public static void main(String args)

{

SpringApplication.run(App.class, args);

}

}


Is there something more that I need to do here? I thought it's simply a boot and autoconfigure by default.










share|improve this question
















I created a very simply SpringBoot project using my groupId and artifactId. Looks like it doesn't want to kick off and some mappings are missing. But when I use the same package names and classnames as the SPring Boot tutorial which is on spring.io site, it works.



My POM is the following:



<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.spring</groupId>
<artifactId>firstspringboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<url>http://maven.apache.org</url>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.0.3.RELEASE</version>

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

</dependencies>




My Resource 'Greeting'



package com.my.spring.firstspringboot.entities;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class Greeting {

private String id;
private String firstName;
private String lastName;

public Greeting() {

}
public Greeting(String firstName, String lastName) throws NoSuchAlgorithmException {
this.setFirstName(firstName);
this.setLastName(lastName);
this.setId(new StringBuilder().append(SecureRandom.getInstance("SHA1PRNG").nextInt()).append("_").append(System.currentTimeMillis()).toString());
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}

@Override
public String toString() {
return new StringBuilder().append("{n"name":"").append(this.firstName).append(" ").append(this.lastName).append(""n").append(",").append("{n"id":"").append(this.id).append(""").toString();
}
}


And its Controller:



package com.my.spring.firstspringboot.controllers;

import java.security.NoSuchAlgorithmException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.my.spring.firstspringboot.entities.Greeting;

@RestController
public class GreetingController {

@RequestMapping("/")
public String home() {
return "Welcome!";
}

@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(name="name",defaultValue="John") String name) throws NoSuchAlgorithmException {
return new Greeting(name,name);
}

}


And main App



package com.my.spring.firstspringboot.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App

{

public static void main(String args)

{

SpringApplication.run(App.class, args);

}

}


Is there something more that I need to do here? I thought it's simply a boot and autoconfigure by default.







java spring-boot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 19:48









Chirdeep Tomar

1,13021645




1,13021645










asked Nov 12 '18 at 18:04









ha9u63arha9u63ar

3,04943558




3,04943558













  • Please provide the error message

    – Chirdeep Tomar
    Nov 12 '18 at 18:52











  • @ChirdeepTomar It's a 404 not found. It doesn't even hit the controller class.

    – ha9u63ar
    Nov 12 '18 at 19:06













  • Change RequestMapping to GetMapping

    – Chirdeep Tomar
    Nov 12 '18 at 19:09






  • 1





    Put your Application class in the package com.my.spring.firstspringboot. docs.spring.io/spring-boot/docs/current/reference/htmlsingle/…

    – JB Nizet
    Nov 12 '18 at 19:50













  • @ChirdeepTomar I don't think that's the issue here. RequestMapping and RequestController have been designed to automatically handle certain web application based configs. I believe this is due to some inconsistence in package or resource lookup

    – ha9u63ar
    Nov 13 '18 at 8:27



















  • Please provide the error message

    – Chirdeep Tomar
    Nov 12 '18 at 18:52











  • @ChirdeepTomar It's a 404 not found. It doesn't even hit the controller class.

    – ha9u63ar
    Nov 12 '18 at 19:06













  • Change RequestMapping to GetMapping

    – Chirdeep Tomar
    Nov 12 '18 at 19:09






  • 1





    Put your Application class in the package com.my.spring.firstspringboot. docs.spring.io/spring-boot/docs/current/reference/htmlsingle/…

    – JB Nizet
    Nov 12 '18 at 19:50













  • @ChirdeepTomar I don't think that's the issue here. RequestMapping and RequestController have been designed to automatically handle certain web application based configs. I believe this is due to some inconsistence in package or resource lookup

    – ha9u63ar
    Nov 13 '18 at 8:27

















Please provide the error message

– Chirdeep Tomar
Nov 12 '18 at 18:52





Please provide the error message

– Chirdeep Tomar
Nov 12 '18 at 18:52













@ChirdeepTomar It's a 404 not found. It doesn't even hit the controller class.

– ha9u63ar
Nov 12 '18 at 19:06







@ChirdeepTomar It's a 404 not found. It doesn't even hit the controller class.

– ha9u63ar
Nov 12 '18 at 19:06















Change RequestMapping to GetMapping

– Chirdeep Tomar
Nov 12 '18 at 19:09





Change RequestMapping to GetMapping

– Chirdeep Tomar
Nov 12 '18 at 19:09




1




1





Put your Application class in the package com.my.spring.firstspringboot. docs.spring.io/spring-boot/docs/current/reference/htmlsingle/…

– JB Nizet
Nov 12 '18 at 19:50







Put your Application class in the package com.my.spring.firstspringboot. docs.spring.io/spring-boot/docs/current/reference/htmlsingle/…

– JB Nizet
Nov 12 '18 at 19:50















@ChirdeepTomar I don't think that's the issue here. RequestMapping and RequestController have been designed to automatically handle certain web application based configs. I believe this is due to some inconsistence in package or resource lookup

– ha9u63ar
Nov 13 '18 at 8:27





@ChirdeepTomar I don't think that's the issue here. RequestMapping and RequestController have been designed to automatically handle certain web application based configs. I believe this is due to some inconsistence in package or resource lookup

– ha9u63ar
Nov 13 '18 at 8:27












2 Answers
2






active

oldest

votes


















0














Try to add http method in your requestMapping



@RequestMapping(path = "/hello", method=RequestMethod.GET)


or try removing first endpoint which you have declared with path "/"






share|improve this answer































    0














    According to the documentation (Thanks to @JBNizet for pointing that out), I needed to keep my main application under the package name com.my.spring.firstspringboot



    The reason is that Spring looks immediately under the firstspringboot subpackage to find the execution class since it's the artifact ID.



    The correct approach should probably be the following:



    1) Keep the app runner class in higher subpackage than resource/controller classes.



    e.g com.my.firstapplication.App, com.my.firstapplication.resources.Resource etc.



    2) If I rely on manual settings, use @EnableAutoConfiguration and @ComponentScan



    3) If I am relying on Spring to do it - it's @SpringBootApplication






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267730%2fspringboot-doesnt-work-except-when-hello-is-typed%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Try to add http method in your requestMapping



      @RequestMapping(path = "/hello", method=RequestMethod.GET)


      or try removing first endpoint which you have declared with path "/"






      share|improve this answer




























        0














        Try to add http method in your requestMapping



        @RequestMapping(path = "/hello", method=RequestMethod.GET)


        or try removing first endpoint which you have declared with path "/"






        share|improve this answer


























          0












          0








          0







          Try to add http method in your requestMapping



          @RequestMapping(path = "/hello", method=RequestMethod.GET)


          or try removing first endpoint which you have declared with path "/"






          share|improve this answer













          Try to add http method in your requestMapping



          @RequestMapping(path = "/hello", method=RequestMethod.GET)


          or try removing first endpoint which you have declared with path "/"







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 20:16









          Sayantan MandalSayantan Mandal

          243212




          243212

























              0














              According to the documentation (Thanks to @JBNizet for pointing that out), I needed to keep my main application under the package name com.my.spring.firstspringboot



              The reason is that Spring looks immediately under the firstspringboot subpackage to find the execution class since it's the artifact ID.



              The correct approach should probably be the following:



              1) Keep the app runner class in higher subpackage than resource/controller classes.



              e.g com.my.firstapplication.App, com.my.firstapplication.resources.Resource etc.



              2) If I rely on manual settings, use @EnableAutoConfiguration and @ComponentScan



              3) If I am relying on Spring to do it - it's @SpringBootApplication






              share|improve this answer




























                0














                According to the documentation (Thanks to @JBNizet for pointing that out), I needed to keep my main application under the package name com.my.spring.firstspringboot



                The reason is that Spring looks immediately under the firstspringboot subpackage to find the execution class since it's the artifact ID.



                The correct approach should probably be the following:



                1) Keep the app runner class in higher subpackage than resource/controller classes.



                e.g com.my.firstapplication.App, com.my.firstapplication.resources.Resource etc.



                2) If I rely on manual settings, use @EnableAutoConfiguration and @ComponentScan



                3) If I am relying on Spring to do it - it's @SpringBootApplication






                share|improve this answer


























                  0












                  0








                  0







                  According to the documentation (Thanks to @JBNizet for pointing that out), I needed to keep my main application under the package name com.my.spring.firstspringboot



                  The reason is that Spring looks immediately under the firstspringboot subpackage to find the execution class since it's the artifact ID.



                  The correct approach should probably be the following:



                  1) Keep the app runner class in higher subpackage than resource/controller classes.



                  e.g com.my.firstapplication.App, com.my.firstapplication.resources.Resource etc.



                  2) If I rely on manual settings, use @EnableAutoConfiguration and @ComponentScan



                  3) If I am relying on Spring to do it - it's @SpringBootApplication






                  share|improve this answer













                  According to the documentation (Thanks to @JBNizet for pointing that out), I needed to keep my main application under the package name com.my.spring.firstspringboot



                  The reason is that Spring looks immediately under the firstspringboot subpackage to find the execution class since it's the artifact ID.



                  The correct approach should probably be the following:



                  1) Keep the app runner class in higher subpackage than resource/controller classes.



                  e.g com.my.firstapplication.App, com.my.firstapplication.resources.Resource etc.



                  2) If I rely on manual settings, use @EnableAutoConfiguration and @ComponentScan



                  3) If I am relying on Spring to do it - it's @SpringBootApplication







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 8:44









                  ha9u63arha9u63ar

                  3,04943558




                  3,04943558






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267730%2fspringboot-doesnt-work-except-when-hello-is-typed%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Full-time equivalent

                      Bicuculline

                      さくらももこ