Search code examples
javaazuremavenintellij-ideaspring-initializr

How do I add a Spring Initializr dependency (eg Microsoft Azure) after the project is created?


I'm trying to add the dependencies azure-support and azure-storage to an existing java spring project in IntelliJ.

I know how to do it using Spring Initializr when starting a new project: then I can add the dependency to the project before creating it.

However I find myself needing to add Azure Storage to an existing project, and I'm stuck.

When I searched for how to do it, numerous sources just give the xml snippet to add to the pom.xml. I've tried simply updating the pom.xml file with the correct dependencies, but this doesn't work. Maven can't seem to find the azure-dependencies I need, IntelliJ colors them red and says that they can't be found. I even tried copying the configuration from the pom.xml file of a working spring project with the right dependencies installed, but with the same result. This does kinda make sense to me since they're not yet installed as far as I can tell.

I've also tried adding them via the 'Project Structure', but I can't find how to do it. I can only find the dependencies I need in the Spring Initializr, and I know of no way to access it but to create a new module, and that doesn't feel like right the way to do it since it adds a whole new project folder structure.

I would greatly appreciate any help! As you can tell I'm new to this kind of thing.


Solution

  • Just go to https://start.spring.io/ add Dependency like in new project (Ctrl+B), next use Explore (Ctrl+Space) and copy needed dependencies to Yours pom.xml file Dont forget to check properties section and also refreshing your project and download new dependencies in IDE.

    <properties>
    <java.version>11</java.version>
    <azure.version>3.4.0</azure.version></properties>
    
      <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.azure.spring</groupId>
        <artifactId>azure-spring-boot-bom</artifactId>
        <version>${azure.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>