i got this project structure :
api
src/main/java -some classes reports / -screenshots - imageOne.png
i want to serve the imageOne.png like this localhost:8080/imageOne.png
i got this configuration
@Configuration public class Configurer implements WebMvcConfigurer { private static final Logger LOG = LoggerFactory.getLogger(Configurer.class); private final String RESOURCE_LOCATION = "file:/api/reports/screenshots"; private final String ANT_PATH_EXPRESSION="/**"; @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry .addResourceHandler(ANT_PATH_EXPRESSION) .addResourceLocations(RESOURCE_LOCATION); } /** @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(ApiRestApplication.class); } */ @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**"); } but is not working and everytime i do localhost:8080/imageOne.png is returning:
There was an unexpected error (type=Not Found, status=404). i need help to find where i mess up in the code
classpath:- in your code above is prefixed withfile:- why are you usingfile:?/apiprefix doing?