简体   繁体   中英

Unable to hit rest service running with spring boot

I have configured restful webservice and hosted with the help of Spring Boot. But I'm not able to hit the service. And getting Response Status: -1 - Request Failed (Canceled or Timed-Out)

Logs:-

⁃   2017-10-08 18:33:33.149  INFO 6806 --- [           main] com.mypleaks.PleaksRSApp                 : Starting PleaksRSApp on 3inmderaj1.local with PID 6806 (/Users/deraj/home/code/leaks-rs/mypleaks-rs/myPleaks-RS/target/classes started by deraj in /Users/deraj/home/code/leaks-rs/mypleaks-rs/myPleaks-RS)
⁃   2017-10-08 18:33:33.155  INFO 6806 --- [           main] com.mypleaks.PleaksRSApp                 : No active profile set, falling back to default profiles: default
⁃   2017-10-08 18:33:33.202  INFO 6806 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@311bf055: startup date [Sun Oct 08 18:33:33 IST 2017]; root of context hierarchy
⁃   2017-10-08 18:33:33.998  INFO 6806 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'requestContextFilter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.class]] with [Root bean: class [org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
⁃   2017-10-08 18:33:34.276  INFO 6806 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
⁃   2017-10-08 18:33:34.372  INFO 6806 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$af71e9e1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
⁃   2017-10-08 18:33:34.745  INFO 6806 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
⁃   2017-10-08 18:33:34.756  INFO 6806 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
⁃   2017-10-08 18:33:34.756  INFO 6806 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6

Resource :- 在此处输入图片说明

Request:- 在此处输入图片说明

Response:- 在此处输入图片说明

It seems that you are using the annotations from the javax. package instead of the spring ones.

Try using @RestController on the class level and @RequestMapping on the method level (all other annotations should be from the spring package also):

@RestController
@RequestMapping(path = "/place")
public class PlaceResource{


   @RequestMapping(method = RequestMethod.GET, path="/countries")
   public Response getCountries(..){..}
}

Sorry Guys, Its was terrible mistake from my side. I had used below code in my application.

public class NotificationEngine implements InitializingBean {

@Override
public void afterPropertiesSet() throws Exception {"Here I was running some stupid endless process, Due to which the tomcat was not getting up completely and because of that Iwas getting this issue."}}

Please check that you have following dependency in your pom.xml, If it is not there please add it and re-run.

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM