This document discusses best practices for deploying Java applications based on the 12 Factor App methodology. The 12 factors are codebase, dependencies, configuration, backing services, build and release, processes, port binding, concurrency, disposability, development and production parity, logs, and admin processes. Adhering to practices like separating configuration from code, making processes disposable and reproducible, and running admin tasks separately can improve an application's scalability, maintainability, and portability. The document argues that by adopting this methodology, Java applications can avoid common problems and perform as well as applications in other languages.
37. Configuration belongs in the environment,
not in the application
Configuration should be strictly
separated from code
| Disposable | Parity | Config |
47. import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.*;
public class Main {
public static void main(String[] args) throws Exception {
Server server = new Server();
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new App()), "/*");
server.start();
server.join();
}
}