This is a simple Java web app to get started.
- Java 11
- Maven 3
- Apache Tomcat 9
If a tomcat server is already installed and running, you can build and deploy the app with one of the following methods:
Before deploying with maven, add the following to your settings.xml
file.
There are two locations where the settings.xml file may be found:
- The Maven install:
${maven.home}/conf/settings.xml
- A user’s install:
${user.home}/.m2/settings.xml
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>admin</password>
</server>
NB: The username and password are the ones you use to log into the tomcat server.
Then, run the following command:
mvn tomcat9:deploy
If you don't use maven, you can build the app and copy the war file to the tomcat webapps folder.
mvn clean package
cp target/*.war /path/to/tomcat/webapps
- Assume the tomcat server is running on port 8080, then you can access the app at http://localhost:8080/java-web
There is a method which allows you to run the app without deploying it. This is useful for development purposes.
mvn tomcat9:run