I have an app that's entirely configured by annotation - no web.xml - that I want to run in embedded Tomcat from Eclipse.
I can find lots of examples that rely on specifying a WEB-INF/classes
dir, but I would rather run it entirely from the Eclipse classpath.
Here is my launcher:
public static void main(String[] args) throws Exception {
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir("<work dir>");
Context ctx = tomcat.addWebapp("/myapp", "<app base>");
StandardJarScanner scan = (StandardJarScanner) ctx.getJarScanner();
scan.setScanClassPath(true);
scan.setScanBootstrapClassPath(false); // just guessing here
tomcat.start();
tomcat.getServer().await();
}
The app starts up - I can get the static content, but the annotation-configured elements are not picked up.
I'm using the tomcat-7-embed
distribution.
Is this possible to do?