• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem with @RestController

 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use @RestController in a spring application but I  cannot find the import; I keep reading on the internet that I should have a dependency for spring-webmvc in the pom, but I already have one. My pom is

I also added something I found in an internet page about @RestController

I have been exploring the internet for several days, bu I still haven't found the solution.
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you need to add spring-web dependency

<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>5.1.0.RELEASE</version>
</dependency>
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<spring.version>3.1.2.RELEASE</spring.version>

RestController annotation didn't appear until (I think) Spring 4.

You need to upgrade to a newer version of Spring.
 
Alejandro Barrero
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Tushar Goel; I changed <spring.version>3.1.2.RELEASE</spring.version> to <spring.version>5.1.0.RELEASE</spring.version> and it is working fine.
 
Alejandro Barrero
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something incredible is happening. When I run the application I am getting 404 error "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." . ngly, the problem hapens before I update the project with Maven. The problem happens with Pivota tc Server, or with a new server. I have had this problem before for several days and I haven't been able to find a solution. Of course, if I revert the change in <spring.version> the problem disapears.
On the other hand, if I only change the version for spring-web (which was my original problem) I am getting the errors
Description Resource Path Location Type
The project was not built since its build path is incomplete. Cannot find the class file for org.springframework.context.annotation.AnnotationConfigRegistry. Fix the build path then try building this project Spring Data Chapter-2 Unknown Java Problem
The type org.springframework.context.annotation.AnnotationConfigRegistry cannot be resolved. It is indirectly referenced from required .class files DataJPAExampleInitializer.java /Spring Data Chapter-2/src/main/java/com/packtpub/springdata/jpa/config line 26 Java Problem
 
Alejandro Barrero
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem with "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." still continues.
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic