gpt4 book ai didi

java - 如何使用 Maven 组件插件打包 Spring Boot Web 应用程序

转载 作者:太空宇宙 更新时间:2023-11-04 10:35:36 24 4
gpt4 key购买 nike

my web application structure

这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>tally</artifactId>
<groupId>win.bestyyt</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>web</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</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-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>win.bestyyt</groupId>
<artifactId>service</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>

<configuration>
<repositoryLayout>flat</repositoryLayout>
<configurationDirectory>conf</configurationDirectory>
<configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<assembleDirectory>${project.build.directory}/tally</assembleDirectory>
<extraJvmArguments>-Xms256m</extraJvmArguments>
<binFileExtensions>
<unix>.sh</unix>
</binFileExtensions>
<platforms>
<platform>windows</platform>
<platform>unix</platform>
</platforms>
<repositoryName>lib</repositoryName>
<programs>
<program>
<mainClass>win.bestyyt.web.Application</mainClass>
<name>start</name>
</program>
</programs>
</configuration>
</plugin>
</plugins>
</build>
</project>

运行 package 命令后,我得到如下所示的目录结构,它是扁平的。

structure after package

我发现所有资源仍在“web-1.0-SNAPSHOT.jar”中 jar structure(sorry for the resolution)

当我执行start.bat时,它不断重新启动。

restarting

我的问题是:

1、如何获取分层资源目录?

2、如何让程序正确运行? (不要一直重启)

最佳答案

您尝试过spring boot maven plugin吗?反而? Spring 制作了自己的插件以避免使用程序集或其他相关插件。

看起来 Spring 正在尝试关闭您的数据源两次。尝试将其添加到您的 java 配置中:

@Bean(destroyMethod = "")
public DataSource dataSource()

关于java - 如何使用 Maven 组件插件打包 Spring Boot Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49525183/

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