Question about the 12 factor principles and, specifically, the dependencies step:


From how I read this, the general idea is that you want code that doesn't rely on system wide packages (so centralized libraries following a DRY principle is what I gather) and those dependencies should be isolated (meaning packaged with the application in such a way that no reliance on outside dependencies are necessary).

In Java world, a POM would handle the manifest part of this and you could introduce dependency management solutions such as Nexus to centralize repositories across code bases.

My question is about external dependencies, such as the reliance on a web server (Jetty, Tomcat, etc). It's not crazy to see embedded web servers in projects now - but what about projects that don't have that architecture, instead relying on an external web application? How does that fit into the 12 factor disciplines? It's not technically a "library" dependency, as this step seems to suggest.

1 Answer 1


What 12factor is pushing you towards is more of a microservice approach, where every app is an independent network service. Your app should not depend on a particular server to run, it should be a server.

Of course your application might also need to communicate with other network services, for example a database. The 12factor solution is to treat such external services as configuration. A typical approach is to provide the application with an environment variable that contains an URL under which the network service can be reached.

It turns out that Docker containers (and similar technologies, in particular Kubernetes) are a pretty good model for 12factor apps. The container encapsulates any potential dependencies (can't access stuff on the host system), and the only thing exposed by a typical container is an open network port. The host system can then forward the port to make the service available to the world.

There is an argument that in the Java world, instead of a container, you'd rather use something like a WAR or JAR (especially since Java 9 makes dependency isolation possible), and that instead of a host operating system you'd have a Java container like Tomcat/Catalina. While this makes it possible to get some of the 12factor advantages, you're still limited to staying within the JVM. Going native is far more flexible, even if that native solution is actually a JVM-based server running your app. My personal opinion is that any of these JavaEE-isms, servlets, and deployments via WARs are completely anachronistic in today's environment. If you want to use Java (which is perfectly fine), just embed a Jetty server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.