【发布时间】:2021-12-28 04:46:50
【问题描述】:
我想将 Spring Boot 和 Angular 应用程序部署为单个 war 文件。我尝试过如下操作,
在 Angular 应用程序中创建了一个 build.gradle 文件
plugins {
id 'java'
id "com.moowork.node" version "1.3.1"
}
// 2
node {
version = '10.15.3'
npmVersion = '6.9.0'
download = true
}
// 3
jar.dependsOn 'npm_run_build'
// 4
jar {
from 'dist/projectName' into 'static'
}
在spring boot项目的build.gradle文件中添加如下内容,
implementation(project(':angularProject')
在 Spring Boot 项目的 settings.gradle 文件中添加以下内容,
include ':angularProject'
project(':angularProject').projectDir = new File('../angularProject')
当我构建 spring boot 项目时,我可以在 spring boot 项目位置看到 angularProject,但我希望它自动显示在 spring boot 项目的资源文件夹中的 static 文件夹中。我错过了什么吗?非常感谢任何帮助。
编辑:
现在,在构建项目时出现以下错误
Could not determine the dependencies of task ':war'.
> Could not resolve all task dependencies for configuration ':runtimeClasspath'.
> Could not resolve project :frontendProject.
Required by:
project :
> No matching variant of project :frontendProject.was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally but:
- Variant 'apiElements' capability backendProjectName:frontendProject:unspecified declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 15 and the consumer needed a runtime of a component compatible with Java 8
- Variant 'runtimeElements' capability backendProjectName:frontendProject:unspecified declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 15 and the consumer needed a component compatible with Java 8
谢谢。
【问题讨论】:
标签: java angular spring-boot gradle integration