Nanor Nanor - 29 days ago 4x
Java Question

Spring producing 404 for valid URL

I'm building a simple Spring application with the goal of returning "Hello world" as a foundation to build upon. I set up a clean project last night following this guide which worked and now I'm trying to bring an already existing project to the same functionality.

I have two files called
tasked with returning a string when a certain URL is hit. When I visit
it renders my
with a link to the URL I wish to return a string at. When I visit the URL
it returns a 404.


package application;

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

public class ApplicationConfig {

public static void main(String[] args) { (ApplicationConfig.class, args);


and my

package controller;

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

public class Controller {

public String greeting() {
return "Hello";

As far as I see
should produce a page that just reads "Hello" but this isn't the case. What is the issue?

Here is my
and what my project structure looks like, should they be relevant.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""









Your entrypoint class is in application package and is in controller package.

SpringBoot scans for Spring components in the package( and sub-packages) where EntryPoint class is.

So move your controller to application or any nested package under application.