Java EE (and Microservice) Quickstart 📎
-
Create Thin WAR project with:
Result: 24 lines ofmvn archetype:generate -Dfilter=com.airhacks:javaee7-essentials-archetype
. (see: Setting Up Java EE 7 Projects With Maven 3)pom.xml
. Thepom.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 filebeans.xml
(one tag), was created to enable Depenency Injection (DI) everywhere and the annotated classJAXRSConfiguration
activates JAX-RS under theresources
uri. The generated Thin WAR project is a production ready template for Java EE / Microservices / Thin WARs. - 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!"; } }
- 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. - ...or download NetBeans "Java EE Edition", open the project, and click "run".
- 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.