See the documentation page for up-to-date information.
App attributes
You can now register attributes on the Javalin instances by calling app.attribute(Class, Object)
.
These attributes can be retrieved on the instance by calling app.attribute(Class)
,
or inside Handlers by calling ctx.appAttribute(Class)
.
As an example, here’s how to make a ConnectionPool
available to every Handler:
Javalin app = Javalin.create()
.attribute(ConnectionPool.class, new ConnectionPool());
.get("/some-path", SomeOtherClass::controller)
.start(7070);
class SomeOtherClass {
static void controller(Context ctx) {
Connection c = ctx.appAttribute(ConnectionPool.class).getConnection()
}
}
Custom Jetty HandlerCollection
It’s now possible to add a custom HandlerCollection
to the Jetty instance that Javalin uses.
Javalin is added at the end of the collection.
Improved Java 9-11 support
Javalin now uses the automatic module name io.javalin
for Java9+ projects.
All of Javalin’s tests run against JDK8, JDK9, JDK10, and JDK11.
Jackson improvements
- The Jackson
ObjectMapper
is now available throughJavalinJackson.getObjectMapper()
. - The dependency checker will now advice you to add the
jackson-module-kotlin
dependency if you’re using Jackson from Kotlin.
Validator fixes
- Initially, the
notNullOrEmpty
check was performed in the constructor. It has now been moved to thegetOrThrow()
/asClass()
methods. - The
Validator
used to swallow exceptions for unregistered converters. This has been fixed. - Added overloads to the
check
method.
Misc bugfixes
- When handling static files, Javalin used to mark any file with a path starting with “/immutable” as immutable. Javalin now requires files to be in a directory named exactly “immutable” as the docs specify.
- The response exceptions (
HttpResponseException
) used to have amsg
property, this has been deprecated in favor of the standardmessage
property on exceptions. - It’s no longer possible to set/replace an
AccessManager
after the Server has started.
Thanks to all contributors
This release was created with the help of seven different contributors. If you want to get involved, head on over to https://github.com/javalin/javalin