adam bien's blog

Java EE (and Microservice) Quickstart 📎

  1. Create Thin WAR project with: mvn archetype:generate -Dfilter=com.airhacks:javaee7-essentials-archetype. (see: Setting Up Java EE 7 Projects With Maven 3)

    Result: 24 lines of pom.xml. The pom.xml only conatins a single dependency to Java EE 7 API. In real world projects you will only need to add test dependencies like JUnit or Mockito. The file beans.xml (one tag), was created to enable Depenency Injection (DI) everywhere and the annotated class JAXRSConfiguration activates JAX-RS under the resources uri. The generated Thin WAR project is a production ready template for Java EE / Microservices / Thin WARs.
  2. Create a JAX-RS resource, like .e.g.
            
        import javax.ws.rs.GET;
        import javax.ws.rs.Path;
        
        @Path("message")
        public class HelloResource {
    
            @GET
            public String message() {
                return "works!";
            }       
        }
    
    
  3. Perform mvn package and copy the Thin WAR ./target/[NAME].war (~4 kB) into the autodeploy / deploy folder of Java EE 6 / 7 / 8 application server of your choice.
  4. ...or download NetBeans "Java EE Edition", open the project, and click "run".
  5. Open the browser with: http://localhost:8080/[NAME]/resources/message

Use a full profile Java EE application servers (Payara, WildFly, TomEE, WebLogic, Websphere Liberty Profile). The download size varies between 55 MB and 200 MB. The runtime overhead is around 50 MB RAM (see live memory profiling: "The (RAM) Overhead Of Java EE Application Servers").

For mainstream (microservices) projects there is no further tuning, configuration or optimization required.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.