Streamlining Payara Micro Development with Dev Mode
Published on 24 Apr 2024
by Gaurav GuptaIntroduction
Payara Micro, a lightweight and flexible microservices runtime platform, offers a seamless development experience through its Maven plugin. In this guide, we'll explore the Dev Mode of Payara Micro Maven plugin, focusing on the dev goal. This goal is tailored to streamline development by enabling various features for an efficient workflow.
Features in Dev Mode
- Auto Deploy: Your application is automatically compiled and deployed upon saving files.
- Eliminates Manual Steps: No more manual builds, packaging and redeployment required after every change.
- Focus on Code: This lets developers stay directly engaged with the code and the results of their changes without workflow interruptions.
- Rapid Iteration: Smaller feedback loop accelerates development and testing cycles.
- Live Reload: The browser refreshes automatically upon redeployment.
- Instant Feedback: Changes are immediately visualized in the browser, providing near real-time feedback.
- Seamless UI Tweaking: Especially beneficial for front-end development, like JSF. No more manual refreshes needed.
- Integrated Experience: Pairs perfectly with auto-deploy for seeing the effects of your code modifications almost instantly.
- Persistent Session State: Session state is persisted across multiple re-deployments.
- Preserves Context: Avoids losing user-related data (e.g., shopping cart contents, login information) during development when the application redeploys.
- Realistic Testing: Emulates production-like user journeys through your application without disruptions caused by redeployments.
- Debugging: Helps isolate issues that might be influenced by session state or user flow across multiple steps.
- Readable Logging: Log format is enhanced for improved readability
- Faster Troubleshooting: Well-formatted logs with clear timestamps and structure make it easier to parse and find relevant information when debugging.
- Less Cognitive Load: Easier-to-read logs reduce the mental effort required to decipher complex issues.
- Customization: Some dev modes might allow further customization of log formatting to match individual developer preferences.
Combined, these Dev Mode features foster:
-
- Productivity: Developers spend less time on repetitive tasks and more time coding.
- Quality: Instant feedback and context preservation can lead to catching bugs and UI inconsistencies earlier in the development process.
- Developer Satisfaction: A smoother workflow and less frustration contribute to a more enjoyable development experience.
Getting Started with Payara Starter
- Open Payara Starter: Navigate to Payara Starter.
- Project Configuration:
- Select "Maven Project" as the project type under the Project Details section.
- Choose "Jakarta EE 10" as the Jakarta EE version.
- Set "Payara Micro" as the Payara Platform.
- Select "Maven Project" as the project type under the Project Details section.
- Generate Application: Click on the "Generate" or "Download" button to generate your Payara Micro Maven project.
- Extract the Application: After downloading, extract the generated application to a location of your choice.
Building and Running the Application via Commandline
Now that you have your Payara Micro Maven project, follow these steps to build and run it using the mvn package payara-micro:dev command:
- Open a terminal or command prompt.
- Navigate to the directory where you extracted the generated Payara Micro Maven project.
- Build the Application: Run the following Maven command to build the application and create the necessary artifacts: mvn package payara-micro:dev
- Watch the Magic Happen: The dev goal initiates Payara Micro in development mode, enabling features such as auto deploy, live reload, and more.
- Monitor the Console: Payara Micro will start and you'll see relevant logs in the console.
- Access the Application: Once Payara Micro is up and running, the application home page will be automatically opened in the browser.
- Test Live Reload: Navigate through the application from the home page to your preferred page. Open the source code in your IDE, make updates, and save it.
- Incremental Compilation: The Dev Mode running in the background will start incrementally compiling the changed source code.
- Background Deployment: The application will be deployed in the background, and the browser page will be refreshed automatically.
Building and Running the Application in IntelliJ
IntelliJ IDEA provides a powerful integrated development environment for Java developers. Here's how you can configure and run your Jakarta EE Web project in IntelliJ:
-
Open IntelliJ IDEA: Launch IntelliJ IDEA and open your Jakarta EE Maven Web project.
-
Configure Payara Micro: Navigate to "Edit Configurations" from the top-right corner dropdown menu or by selecting "Run" > "Edit Configurations" from the menu bar.
-
Add Payara Micro Configuration: Click on the "+" icon and select "Maven" from the dropdown. In the configuration settings, specify the following:
-
Name: Provide a name for your configuration (e.g., Payara Micro Dev).
-
Command line: Enter the Maven command to run Payara Micro in dev mode. For Payara Micro Maven plugin upgrade version to 2.2 and use dev goal, use the following command: package fish.payara.maven.plugins:payara-micro-maven-plugin:2.2:dev
-
Working directory: Set the path to your Payara Micro Maven project directory.
-
4. Apply Configuration: Click "Apply" to save the configuration settings.
5. Run the Project: Now, simply build and click on the green "Run" icon or select "Run" > "Run 'Payara Micro Dev'" from the menu bar.
6. Development Mode: IntelliJ will start the project in dev mode using Payara Micro. Any changes made to the source code will trigger auto deployment and live reload.
By following these steps, you can seamlessly build, run, and develop your Payara Micro Maven project in IntelliJ IDEA, leveraging the efficient features provided by the Payara Micro Maven plugin.
Conclusions
Integrating Payara Micro into your Maven projects becomes a breeze with the Payara Micro Maven Plugin. The dev goal, designed for productive development, enhances your workflow with features such as auto-deploy, live-reload and more. For detailed information and comprehensive documentation on the Payara Micro Maven Plugin, please refer to the official Payara documentation: Payara Micro Maven Plugin Documentation, download your Jakarta EE starter here and get productive. Happy Coding!
Related Posts
The Payara Monthly Catch - November 2024
Published on 28 Nov 2024
by Chiara Civardi
0 Comments
The Payara Monthly Catch - October 2024
Published on 30 Oct 2024
by Chiara Civardi
0 Comments