【发布时间】:2021-05-15 22:11:29
【问题描述】:
我已经创建了一个 spring boot 后端和一个 angular 前端,现在我想使用 sprint boot 在 8080 上运行,其主页显示 index.html(来自 angular)。
我使用 ng build --prod 命令在 Angular 中创建了 dist 文件夹并复制到 (src/main/resources/static) 文件夹中。enter image description here
除此之外,我还阅读了许多关于此的 stackoverflow 帖子,并尝试通过添加来创建一个 war 文件
<packaging>war</packaging>
在 pom.xml 中(虽然我不知道如何创建战争) 事实上,它在目标文件夹中创建了一个战争文件(AIeDD-0.0.1-SNAPSHOT)。 有些帖子说要在tomcat服务器上部署战争,但我不知道该怎么做。
现在我不知道该怎么办??
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.cdac</groupId>
<artifactId>AIeDD</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>AIeDD</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</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-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
标签: java angular spring spring-boot