【问题标题】:Intellij cannot run Spring app with a certain dependencyIntellij 无法运行具有特定依赖项的 Spring 应用程序
【发布时间】:2015-04-01 17:54:48
【问题描述】:

我正在使用 spring 和 maven 开发一个 webapp,并且希望能够从本地 tomcat 服务器和 intellij 中运行该应用程序。这种依赖似乎是罪魁祸首。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

当我删除此依赖项时,应用程序在 intellij 中运行良好,因为存在其他依赖项,但随后无法在 tomcat 上运行。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

我可以设置一些东西来自动为 intellij 使用正确的依赖项吗?

【问题讨论】:

    标签: spring maven tomcat intellij-idea


    【解决方案1】:

    您可以在 pom.xml 中设置 maven 配置文件,然后为 Intellij 使用特定配置文件。 Intellij 允许您在运行构建时选择配置文件。

    <profiles>
     <profile>
        <id>intellij</id>
        …
        <dependencies>
            <dependency>…</dependency>
        </dependencies>
        …
     </profile>
     <profile>
        <id>release</id>
        …
        <dependencies>
            <dependency>…</dependency>
        </dependencies>
        …
     </profile>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-12
      • 2019-12-23
      • 2020-12-01
      • 1970-01-01
      • 2016-06-20
      • 1970-01-01
      • 2018-02-14
      • 2010-10-08
      相关资源
      最近更新 更多