Connect Service to Component - Auto Configuration

🕓 5 minutes

What you’ll learn

How to add new services such as Kafka or Redis to your component, so that CodeNow will automatically generate the configuration and connect your component to the chosen service during deployment.
Auto-configuration generates files to your repository, so you don't have to write them yourself. It also adds the required dependencies to the pom.xml file.

Prerequisites

  • You want to create a new application component using Java Spring Boot scaffolder and want to auto-configure services.
  • Choose the existing application or Create a New Application.
  • Create New Service (e.g. Apache Kafka)

Step

  1. While creating a new Spring Boot component, click on the "Add new connection" button and choose one of the services.

  2. After you've created a component, you can see your generated configuration in the project source code inside the src/main/java/com/codenow/generated package.

    • Please refrain from editing these files yourself as they may be changed or re-generated in the future.

    • Auto-configuration also adds the required dependencies to pom.xml and enables autoconfiguration in src/main/resources/META-INF/spring.factories.

    • You can go to the component details and click "Connection Usage" to see the instructions and generated files names and locations.

  3. When your application will be ready for deployment, you will be able to select a specific service instance for every environment and CodeNow will automatically provide your application with the correct values so that your component will be connected to a chosen service.

Screenshot

Step 1.1

new_connection

Step 1.2

choose_service

Step 1.3

choose_service

Step 2.1

component_details

Step 2.2

connection_usage

Example instructions for Apache Kafka.

example_instructions

What’s next?

See our other manuals: