A Comprehensive Guide to Upgrading from Jooby 2.x to 3.x

Upgrading from Jooby 2.x to 3.x

When upgrading your Jooby application from version 2.x to 3.x, there are several important changes and improvements to be aware of. This guide aims to help you understand the key concepts and adjustments needed for a smooth transition.

Key Changes in Jooby 3.x

1. Java 8+ Requirement

  • Jooby 3.x requires Java 8 or higher.
  • Ensure your development environment is updated accordingly.

2. New Module Structure

  • Jooby 3.x introduces a modular architecture.
  • Applications can be built using separate modules for better organization.

3. Improved Configuration

  • Configuration is now centralized, allowing for easier management.
  • Use application.conf for defining application settings.

4. Routing Changes

  • The routing syntax has been simplified. Example:
get("/hello", req -> "Hello World");
  • Introduced support for route parameters and query parameters.

5. Dependency Injection

  • Jooby 3.x enhances dependency injection capabilities.
  • Simplifies how services are created and injected into routes. Example:
class MyService {
    // Service code here
}

class MyApp extends Jooby {
    {
        use(MyService.class);
    }
}

Migration Steps

1. Update Your Java Version

  • Ensure you are using at least Java 8 or newer.

2. Revise Your Dependencies

  • Update your build configuration (e.g., Maven or Gradle) to include Jooby 3.x dependencies.

3. Refactor Your Code

  • Review and modify your existing routes to align with the new routing syntax.
  • Update configuration files to the new format.

4. Test Your Application

  • After making the changes, thoroughly test your application to ensure everything works as expected.

Conclusion

Upgrading from Jooby 2.x to 3.x involves several key changes, especially around routing, configuration, and modularization. By following the outlined steps and understanding the new features, you can successfully transition to the newer version and take advantage of its improvements.

For more detailed guidance, refer to the Jooby upgrade documentation.