gpt4 book ai didi

java - "update classpath"在Java或SpringBoot中是什么意思?

转载 作者:行者123 更新时间:2023-12-02 10:06:20 25 4
gpt4 key购买 nike

我正在阅读 Spring boot reference guide about the developer tools ,并提到以下内容:

As DevTools monitors classpath resources, the only way to trigger a restart is to update the classpath. The way in which you cause the classpath to be updated depends on the IDE that you are using. In Eclipse, saving a modified file will cause the classpath to be updated and trigger a restart. In IntelliJ IDEA, building the project (Build → Make Project) will have the same effect.

我很困惑,“更新类路径”是什么意思?更准确地说:

  • 如果我在 IDE 中修改文件,它似乎不会更新类路径,这是正确的吗?
  • 如果我在 IntelliJ 中单击“Build”,它似乎会更新类路径,但 IDE 到底做了什么?

最佳答案

需要明确的是,类路径指定项目中用户定义的类的位置(路径)。通常,当更改类(文件)时,需要手动重新启动 Spring Boot 应用程序才能看到操作的更改。

正如您所提到的,spring-boot-devtools 提供了 Automatic Restart :

Applications that use spring-boot-devtools automatically restart whenever files on the classpath change. This can be a useful feature when working in an IDE, as it gives a very fast feedback loop for code changes. By default, any entry on the classpath that points to a folder is monitored for changes. Note that certain resources, such as static assets and view templates, do not need to restart the application.

As DevTools monitors classpath resources, the only way to trigger a restart is to update the classpath. The way in which you cause the classpath to be updated depends on the IDE that you are using. In Eclipse, saving a modified file causes the classpath to be updated and triggers a restart. In IntelliJ IDEA, building the project (Build -> Build Project) has the same effect.

这意味着,使用 IntelliJ,在构建项目(从而更新类路径)时,开发工具将触发应用程序的重新启动。更简单的是,您还可以将 IntelliJ 设置为自动构建并激活 compiler.automake.allow.when.app.running ( here is how )。

关于java - "update classpath"在Java或SpringBoot中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55314207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com