This Spring
example uses a Java
configuration to register a servlet. To test this,
- add a latest
maven-war-plugin
to ignore missingweb.xml
, and
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
</plugins>
</build>
- build a war, and
- create a
Dockerfile
to useTomcat
, and
FROM tomcat
COPY example-05-dispatcher-servlet-code-configuration-2-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/
- build and run a container, and
docker build .
docker run -p 8080:8080 -it <image>
- send a request to
/hello
.
curl -4 -v -XGET http://localhost:8080/hello
However, the tomcat didn't find the controller, and this was what I got:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
What did I wrong, and how can I fix it?