[Spring] Endpoints not being mapped after modifying a controller file

Answered

I'm experimenting with IDEA and considering buying it, but this problem is making me reconsider it. It is hard to accept that a paid IDE has this kind of issue while free ones such as Eclipse things just work fine, but I am willing to try everything because I believe I must be doing something wrong or simply not doing what's best for a Spring project to "just work fine" too.

So, it is a simple issue. I have a project with some controllers. Every file change I build again with Ctrl + F9 command mapped to Ctrl + S, and most of the time any endpoint of that controller file that I had just changed will not be found. For example, take a UserController file, after adding a System.out.println(), it may throw the following below even if I had just accessed it 10 seconds ago.

No mapping for GET /v1/users

It might work normally or not, and the only way to fix this is to manually stop and restart the local server but I don't think I should be fine with it. It is an IDE that claims to maximize productivity and waiting for a file to build just to find out the server needs to be restarted isn't productive. And again, it only happens when using IDEA.

I haven't changed much. I set to build the project automatically and allow the automaking when the app is running, despite guessing it's not necessary since I rebuild the files. I've completely removed IDEA and all its configuration folders, downloaded it again without changing any default configuration, but it persists.

Some weird logs I see is, for example accessing cuisines endpoints, after changing something in the file:

Request 'GET /v1/cuisines' doesn't match 'GET /logout'
Request 'GET /v1/cuisines' doesn't match 'POST /logout'
Request 'GET /v1/cuisines' doesn't match 'PUT /logout'
Request 'GET /v1/cuisines' doesn't match 'DELETE /logout'

Thank you for any help and a possible solution.

0
4 comments

Please provide a sample project and the exact steps to reproduce the issue: https://uploads.services.jetbrains.com/.

Make sure the app is started in debug mode to support hotswapping.

0
Avatar
Permanently deleted user

Hi Serge,

 

The upload ID is 2020_07_12_5xGqPiknEPJ9uGTa.

 

It is a simplified version of my current project. It has only one controller, model, mapper, DTO, and migration. Below is the error that often happens when I edit the controller and try to send a request to one of its endpoints:

 

{
    "timestamp": "2020-07-12T20:55:21.268+00:00",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/v1/cuisines"
}

 

I added the Spring Boot Actuator to my main project and confirmed that in the Endpoints tab, Mappings subtab, the above endpoints did disappear. I also attempted erased the .idea folder and completely removed every file and configuration folder related to IntelliJ IDEA and then downloading it again, as well as using the beta version. Everything resulted in the same error happening randomly between saves. Only with IDEA.

 

The complete project is here: https://www.github.com/mfgabriel92/spring-rest-specialist-course

0

I can't reproduce the issue when using debug mode an no automatic compilation, just Ctrl+F9 to build after making a change to the controller. IDE shows a popup about a reloaded class, I then refresh the URL in the browser and it still works.

What would be the proper steps to reproduce the described problem?

0
Avatar
Permanently deleted user

Hi Serge,

I hadn't tried it like this before. It seems everything is working fine, now.

What I had done was running the project normally, not debugging. Like this, even pressing Ctrl + F9 would cause the issue to happen.

0

Please sign in to leave a comment.