运行应用程序时,Intellij使用哪个配置文件?

发布于 2025-02-13 08:49:05 字数 519 浏览 0 评论 0原文

我有两个maven profiles.一个是dev,它依赖于嵌入式的tomcat

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

和prod,但没有。

在Intellij的右上角,我可以看到两个配置文件。 当我运行检查DEV配置文件时,该应用程序会失败,因为它找不到嵌入式tomcat。

如果我在主配置文件中包含依赖性并删除范围标签,则应用程序加载。 我在做什么错? 当您从Intellij中运行应用程序时,它在哪个配置文件下运行该应用程序?

I have two maven profiles.One is Dev which has a dependency on embedded Tomcat

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

and Prod which has not.

At the upper right corner of Intellij I can see the two profiles.
When I Run Application having checked the Dev profile, the app fails because it can't find the embedded Tomcat.

If I include the dependncy in the main profile and removing the scope tag,the app loads.
What am I doing wrong?
when you do Run Application from within Intellij under which profile does it run the application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若相惜即相离 2025-02-20 08:49:05

提供的范围意味着该依赖关系应由运行应用程序的外部环境(例如应用程序服务器)提供,以防万一您将其部署为战争文件。就您而言,当您在开发环境中运行它时,没有人可以提供这种依赖性,因此指定此范围可能没有意义。这就是当您删除范围元素时它可以工作的原因。

The provided scope means that this dependency is supposed to be provided by the external environment that runs your application, e.g. the application server, in case you deploy it as a war file. In your case, when you run it in the development environment, there is noone to provide this dependency, so specifying this scope probably doesn't make sense. This is the reason it works when you remove the scope element.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文