This should be an easy one, but it's not been so far. I've been working with vert.x 2
for a bit and switched to vert.x 3
recently. I thought I'd try a simple vertx-web example but can't get past a simple serving up of static files.
My server class contains the following snippets:
HttpServer server = vertx.createHttpServer();
Router router = ...;
router.route("/static/*").handler(StaticHandler.create().setCachingEnabled(false));
server.requestHandler(router::accept).listen(ctx.port);
I'm using Eclipse, but have also been trying running vertx
from the the command line. I'm also using Maven. I have three webroot folders, and vert.x
can find none of them:
myproject/webroot
myproject/src/main/resources/webroot
myproject/src/main/java/webroot
Each of those 'webroot's contains an index.html
, and a css/base.css
file.
The first one is in my project's root folder. The second is in the Maven resources folder, and the third should be flat-out on my classpath
. In my Eclipse run config, I added myproject/src/main/resources/webroot to the classpath, and I made sure my working directory was set to 'myproject'. When running from the command line, I'm in the myproject directory, and my script looks like this:
JAVA_OPTS="-Dmyproject.port=8099" CLASSPATH="src/main/java:src/main/resources:target/dependencies/*:target/classes" vertx run com.my.MyProject
No matter what, I always get 404s when I try any of these URLs:
http://localhost:8099
http://localhost:8099/
http://localhost:8099/index.html
http://localhost:8099/static/css/base.css
Anything else I need to be doing?