Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Intellij无法运行具有特定依赖项的Spring应用程序_Spring_Maven_Tomcat_Intellij Idea - Fatal编程技术网

Intellij无法运行具有特定依赖项的Spring应用程序

Intellij无法运行具有特定依赖项的Spring应用程序,spring,maven,tomcat,intellij-idea,Spring,Maven,Tomcat,Intellij Idea,我正在使用spring和maven开发一个webapp,希望能够在本地tomcat服务器和intellij中运行该应用程序。这种依赖似乎是罪魁祸首 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided<

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

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

org.springframework.boot
弹簧启动机tomcat
假如
当我删除此依赖项时,由于另一个依赖项,应用程序在intellij中运行良好,但随后无法在tomcat上运行

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

org.springframework.boot
SpringBootStarterWeb

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

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

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

intellij
…
…
…
释放
…
…
…