title: rest controller not working in spring boot
body: <p><strong>I have checked most similar questions, and don't find the answer.So I can only post a new question.</strong></p>
  
  <p>I can successfully run my application without errors, but the rest api I write can't be access correctly.I have compared my launch log to the <a href="https://spring.io/guides/gs/rest-service/" rel="noreferrer">official tutorials</a>, then I have found out I don't have the similar  log below:</p>
  
  <pre><code>2017-11-13 17:37:50.921  INFO 6503 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2328c243: startup date [Mon Nov 13 17:37:49 CST 2017]; root of context hierarchy
  2017-11-13 17:37:51.061  INFO 6503 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting]}" onto public hello.Greeting hello.GreetingController.greeting(java.lang.String)
  2017-11-13 17:37:51.066  INFO 6503 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity&lt;java.util.Map&lt;java.lang.String, java.lang.Object&gt;&gt; org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
  2017-11-13 17:37:51.067  INFO 6503 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
  2017-11-13 17:37:51.126  INFO 6503 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  2017-11-13 17:37:51.127  INFO 6503 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  2017-11-13 17:37:51.188  INFO 6503 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  </code></pre>
  
  <p>Here are some my java files, Hope anyone can find some keypoint to solve my problem</p>
  
  <p>the main application file:</p>
  
  <pre><code>package com.teachermate;
  
  import com.alibaba.druid.pool.DruidDataSource;
  import com.teachermate.entites.TeacherMateSettings;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.context.properties.EnableConfigurationProperties;
  import org.springframework.context.annotation.Bean;
  import org.springframework.core.env.Environment;
  
  import javax.sql.DataSource;
  
  @SpringBootApplication
  @EnableConfigurationProperties({TeacherMateSettings.class})
  public class JobScheduleApplication {
  
      @Autowired
      private Environment env;
  
      public static void main(String[] args) {
          SpringApplication.run(JobScheduleApplication.class, args);
      }
  
      @Bean
      public DataSource dataSource() {
          DruidDataSource dataSource = new DruidDataSource();
          dataSource.setUrl(env.getProperty("spring.datasource.url"));
          dataSource.setUsername(env.getProperty("spring.datasource.username"));
          dataSource.setPassword(env.getProperty("spring.datasource.password"));
          dataSource.setInitialSize(2);
          dataSource.setMaxActive(20);
          dataSource.setMinIdle(0);
          dataSource.setMaxWait(60000);
          dataSource.setValidationQuery("SELECT 1");
          dataSource.setTestOnBorrow(false);
          dataSource.setTestWhileIdle(true);
          dataSource.setPoolPreparedStatements(false);
          return dataSource;
      }
  }
  </code></pre>
  
  <p>the controller file:</p>
  
  <pre><code>@RestController
  @RequestMapping(path = "/test")
  public class TestController {
    @RequestMapping(method = RequestMethod.GET)
      public JSONObject HelloWorld() {
          JSONObject res = new JSONObject();
          LOGGER.info("HelloWorld Test!");
          res.put("data", "hello world!");
          res.put("errCode", 0);
          return res;
      }
  }
  </code></pre>
  
  <p>the pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.teachermate&lt;/groupId&gt;
      &lt;artifactId&gt;job-scheduler&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;jobSchedule&lt;/name&gt;
      &lt;description&gt;job schedule for teachermate&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.7.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-redis&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                  &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                  &lt;artifactId&gt;tomcat-jdbc&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-configuration-processor&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
              &lt;artifactId&gt;fastjson&lt;/artifactId&gt;
              &lt;version&gt;1.2.39&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.30&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt;
              &lt;artifactId&gt;quartz&lt;/artifactId&gt;
              &lt;version&gt;2.2.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
              &lt;artifactId&gt;guava&lt;/artifactId&gt;
              &lt;version&gt;23.2-jre&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
              &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
              &lt;version&gt;4.3.6&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
              &lt;artifactId&gt;druid&lt;/artifactId&gt;
              &lt;version&gt;1.0.19&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;executable&gt;true&lt;/executable&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>BTW, the rest api works fine before I add some code or library(like druid).<strong>But I don't know what cause it, can anyone help? Or can anyone show me a way to debug it? Thanks!</strong></p>
  
  <p>If you need any other information, just tell me in the comments.</p>
  
  <hr>
  
  <p><strong>update</strong></p>
  
  <p>I have modified the controller in <a href="https://spring.io/guides/gs/rest-service/" rel="noreferrer">official tutorials</a> to </p>
  
  <pre><code>@RestController
  @RequestMapping(path = "/test")
  public class GreetingController {
  
      private static final String template = "Hello, %s!";
      private final AtomicLong counter = new AtomicLong();
  
      @RequestMapping("/greeting")
      public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
          return new Greeting(counter.incrementAndGet(),
                              String.format(template, name));
      }
  
      @RequestMapping(method = RequestMethod.GET)
      public JSONObject HelloWorld() {
          JSONObject res = new JSONObject();
          res.put("data", "hello world!");
          res.put("errCode", 0);
          return res;
      }
  }
  </code></pre>
  
  <p>it works fine!</p>