【问题标题】:Run spring boot application on server在服务器上运行 Spring Boot 应用程序
【发布时间】:2019-08-06 11:15:14
【问题描述】:

我是 Spring 应用程序开发的新手。

如何在 tomcat 服务器的开发阶段运行我的应用程序。

here 我可以看到最终部署的解决方案。每次我需要停止并重新开始时,我只需要在 ui 上更改一些。它杀了我。那你能帮帮我吗?

我的 pom.xml 依赖项是

org.springframework 弹簧绑定 1.0.6

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

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

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

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

【问题讨论】:

  • 你到底在问什么?
  • 我不明白。您可以像在服务器上运行任何其他可执行文件一样运行它。
  • 如果您想刷新应用程序的静态内容,也许这篇文章可以帮助您 - stackoverflow.com/questions/24221922/…
  • 哪里需要频繁启动和停止?日食还是服务器?
  • 将 devtools 依赖项添加到您的项目中。当您进行更改时,它会自动部署项目。

标签: java spring spring-boot tomcat


【解决方案1】:

将 devtools 依赖项添加到您的项目中。

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

每当类路径中的文件发生更改时,使用 spring-boot-devtools 的应用程序都会导致应用程序重新启动。此功能的好处是大大减少了验证所做更改所需的时间。

【讨论】:

  • 托管版本是 2.1.1.RELEASE 工件在 org.springframework.boot:spring-boot-dependencies:2.1.1.RELEASE 中管理这是我现在遇到的错误跨度>
  • 你的项目中添加了 spring-boot-starter-parent 依赖了吗? org.springframework.bootspring-boot-starter-parent2.1.1.RELEASE 摆脱这个错误您添加了启动器父依赖项。
  • 如果你正在使用任何第三方依赖,即hibernate或camel,一个更安全的使用方法是覆盖Boot的依赖管理。当您使用 spring-boot-starter-parent 作为 pom 的父级时,您可以通过覆盖 version 属性来做到这一点。
【解决方案2】:

使用 maven install gol 创建应用程序,生成一个 jar,在您的服务器上运行该 jar > java -jar your_jar.jar

【讨论】:

  • 每次开始开发时都无法创建 jar。
猜你喜欢
  • 2017-07-17
  • 2021-08-20
  • 1970-01-01
  • 2023-01-25
  • 2017-07-16
  • 2019-03-05
  • 2017-12-15
  • 2021-03-02
  • 1970-01-01
相关资源
最近更新 更多