Tiven Wang
chevron_rightServlet chevron_rightMaven chevron_rightTomcat

Cloud Training 1 - Create Maven Project and Deploy to Tomcat

Wang Tiven April 24, 2017
425 favorite favorites
bookmark bookmark
share share





Check Java

java -version




Startup Tomcat

%TOMCAT HOME%\bin\startup.bat




Check Maven

mvn -v

Create Project

1 Generate Project by Maven

mvn archetype:generate -DgroupId=com.tiven -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

2 Build and Package

mvn package

3 Deploy to Tomcat Container

Deploy war into tomcat apache-tomcat-8.5.14\webapps

4 Check your Web Application - jsp

Create a Servlet

1 Create HelloCloud class

package com.tiven;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloCloud extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
        PrintWriter out = response.getWriter();
        out.println("<title>Hello Cloud!</title>");
        out.println("<h1>Hello Cloud!</h1>");

2 Add servlet configures in web.xml



3 Add Servlet Dependencies in pom.xml



4 Re Build and Package

mvn clean packge

5 Check the Servlet

Eclipse IDE Support

mvn eclipse:eclipse -Dwtpversion=2.0

import into eclipse

add tomcat7 plugin in pom.xml


mvn tomcat7:run

Debug in Eclipse IDE

mvndebug tomcat7:run

Run Remote Java Application in Debug Configurations at local port 8000

debug in servlet

download source codes for maven dependencies:

mvn dependency:sources mvn dependency:resolve -Dclassifier=javadoc

or Configure them in eclipse

Similar Posts

  • Try CloudFoundry Try CloudFoundry
  • Maven Best Practices Maven Best Practices
  • Unit Test by Spring MVC Test Framework Testing is an integral part of enterprise software development. Dependency Injection should make your code less dependent on the container than it would be with traditional Java EE development. This topic introduce how to create Unit Test by Spring MVC Test Framework for Java project on HCP
  • Apply Spring Data JPA to Java Project on HCP Spring Data’s mission is to provide a familiar and consistent, Spring-based programming model for data access while still retaining the special traits of the underlying data store. Spring Data JPA, part of the larger Spring Data family, makes it easy to easily implement JPA based repositories. This module deals with enhanced support for JPA based data access layers. It makes it easier to build Spring-powered applications that use data access technologies.
  • Apply Spring Architecture to Java Project on HCP The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. Although the framework does not impose any specific programming model, it has become popular in the Java community as an alternative to, replacement for, or even addition to the Enterprise JavaBeans (EJB) model. I will show you how to apply Spring Frameworks to Java project on HANA Cloud Platform.
  • Persistence Service for Java Maven Project on HCP The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. JPA was defined as part of the EJB 3.0 specification as a replacement for the EJB 2 CMP Entity Beans specification. In this topic I will show you how to create persistence service for Java project on HCP using Java Persistence API (JPA) and it's implementation EclipseLink


Back to Top