gpt4 book ai didi

gwt - Spring Boot + GET 嵌入式配置

转载 作者:行者123 更新时间:2023-12-04 01:09:18 25 4
gpt4 key购买 nike

我想配置 Spring Boot Embedded Servlet Container + GWT。我想要的方式是创建一个 jar/war 文件,它只包含已编译的 gwt 文件和静态资源。我想从 lib/* 加载 jars 并从类路径加载配置文件。

我找不到任何工作示例。实际上有一个,https://github.com/Ekito/spring-boot-gwt ,但所有的依赖项和配置仍在 war 中。

有人可以提出解决方案吗?

最佳答案

经过长时间的搜索和测试,这是我想出的解决方案:

``

<!-- POM -->
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ekito.gwt</groupId>
<artifactId>gwt-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Ekito Spring Boot GWT WebApp</name>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<start-class>fr.ekito.gwt.server.ServerApplication</start-class>
<java.version>1.7</java.version>

<gwtVersion>2.6.0</gwtVersion>
<googleGin>2.1.2</googleGin>
<outputFolder>${project.build.directory}/${artifactId}</outputFolder>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<exclusions>
<exclusion>
<groupId>io.undertow</groupId>
<artifactId>undertow-websockets-jsr</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
</dependency>
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
<version>${googleGin}</version>
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwtVersion}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>GwtWebApp.html</runTarget>
<persistentunitcachedir>${project.build.directory}</persistentunitcachedir>
<deploy>${project.build.directory}/gwt-deploy</deploy>
<webappDirectory>${project.build.directory}/classes/public</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>

``

我的项目结构和原来的项目一样, https://github.com/Ekito/spring-boot-gwt ,除了一些小的变化:
  • 而不是 webapp 文件夹,我有 src/main/resources/public 文件夹,还有 html 和 css 文件。
  • 不需要 web.xml 文件,spring-boot 会处理它。
  • 不需要 WEB-INF 文件夹。

  • 结果,我有一个可运行的 jar,但由 org.springframework.boot.loader.PropertiesLauncher 运行。单个 jar 按预期工作,Tomcat 不按此处所述工作: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-jsp-limitations .

    另外,我可以将 lib 文件夹移到 jar 文件之外,但是我为了设置 loader.path属性,我需要把它放到 jar 文件中的 application.properties 中。我应该可以使用 -Dloader.path 但没有用。

    我会与 Spring 团队核实。但到目前为止,它是有希望的。

    关于gwt - Spring Boot + GET 嵌入式配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28564438/

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