search
HomeJavajavaTutorialIdea how to start multiple SpringBoot projects

    1. Preparation

    Use Idea to build a hello world Spring Boot project.

    Development environment description:

    (1) Spring Boot 2.7.0

    (2) Idea: IntelliJ IDEA 2022.2.2

    (3) OS : Mac OS

    The environment is different, some operations are slightly different, but the overall idea is the same.

    2. Start multiple SpringBoot

    2.1 Solution 1: Modify the port of the configuration file

    In the Spring Boot project, the port number can be configured in the configuration file, so the final The simple solution that can be thought of is to modify the port configuration server.port in the configuration file application.(properties/yml). The specific operations are:

    (1) First configure server.port = 8080, and run the startup class to start the application.

    (2) Modify server.port = 8081 and run the startup class to start the application.

    This will start two Spring Boot applications with different ports. Although this method is simple, its operation experience is not friendly, and modifying the configuration file in an actual project will definitely not work.

    2.2 Solution 2: Edit Configurations of Idea tool

    Use the Edit Configurations provided by Idea to configure application parameters.

    Idea how to start multiple SpringBoot projects

    Click Modify Options to add application parameters:

    Idea how to start multiple SpringBoot projects

    The interface may be slightly different depending on the version of the development tool. , but you can all find Program arguments:

    Idea how to start multiple SpringBoot projects

    Description:

    (1) VM options: VM options is actually the runtime environment we need in the program Variable, it needs to start with -D or -X or -XX, each parameter is separated by a space eg: -Dspring.profiles.active=dev

    (2) Program arguments: Program arguments are passed into main for us String array args[] of the method, which usually starts with --, such as --spring.profiles.active=dev; which is equivalent to -Dspring.profiles.active=dev. If both exist, the Program arguments configuration takes precedence.

    Then add a --server.port=8081 configuration:

    Idea how to start multiple SpringBoot projects

    2.3 Solution 3: Use RunDashboard

    IDEA provides powerful Dashboard functionality (Run Dashboard) can manage the above multi-application startup instances very well, visualize the projects we configure, facilitate the reconfiguration, Run, and Debug of the spring boot project, and simplify our operation steps.

    Add the following configuration in the .idea/workspace.xml file:

    <component name="RunDashboard">
      <option name="configurationTypes">
        <set>
          <option value="SpringBootApplicationConfigurationType" />
        </set>
      </option>
    </component>

    After starting again, you can see the Run Dashboard at the bottom

    Idea how to start multiple SpringBoot projects

    You can copy a configuration here:

    Idea how to start multiple SpringBoot projects

    Idea how to start multiple SpringBoot projects

    In this way, you can start multiple ones:

    Idea how to start multiple SpringBoot projects

    3. Two Spring Boot startups on the same port

    SpringBoot comes with Tomcat, just run SpringApplication.run in the main method directly, and it is not required for access With project name.

    If there are two SpringBoot projects in the idea and the access paths of the controller layer are the same, and since there is no path name, two main methods cannot be run at the same time. If two main methods are run at the same time, the port number must be occupied. How to start two projects at the same time.

    You only need to deploy the war package to the Tomcat server, and there is no need to use SpringBoot's built-in Tomcat server. To access, just enter localhost:8080/project name/path in the URL. In the development tools, you can also use external Tomcat to start.

    The above is the detailed content of Idea how to start multiple SpringBoot projects. For more information, please follow other related articles on the PHP Chinese website!

    Statement
    This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
    How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?Mar 17, 2025 pm 05:46 PM

    The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

    How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management?How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management?Mar 17, 2025 pm 05:45 PM

    The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

    How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?Mar 17, 2025 pm 05:44 PM

    The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

    How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?Mar 17, 2025 pm 05:43 PM

    The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

    How does Java's classloading mechanism work, including different classloaders and their delegation models?How does Java's classloading mechanism work, including different classloaders and their delegation models?Mar 17, 2025 pm 05:35 PM

    Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: How To Unlock Everything In MyRise
    3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    MantisBT

    MantisBT

    Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

    Dreamweaver Mac version

    Dreamweaver Mac version

    Visual web development tools

    ZendStudio 13.5.1 Mac

    ZendStudio 13.5.1 Mac

    Powerful PHP integrated development environment

    MinGW - Minimalist GNU for Windows

    MinGW - Minimalist GNU for Windows

    This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use