我有一个模块化的gradle应用程序:一个服务组件(spring boot,kotlin)和一个角度前端 .

两者都是单独工作,并且在开发过程中应用程序按预期工作我创建了toplevel buildfile,如下所示:

Toplevel gradle文件:

plugins {
    id 'com.gradle.build-scan' version '1.16'
}

buildScan {
    termsOfServiceUrl = 'https://gradle.com/terms-of-service'
    termsOfServiceAgree = 'yes'

    publishAlways()
}

allprojects {
    group = 'my.domain'
    version = '0.0.1-SNAPSHOT'
}

UI角度项目中的gradle文件:

plugins {
    id 'java'
    id 'com.moowork.node' version '1.2.0'
}

node {
  version = '10.13.0'
  npmVersion = '6.4.1'
  download = true
}

jar.dependsOn 'npm_run_build'

jar {
  from 'dist/myproject-ui' into 'static'
}

服务中的gradle文件(spring boot项目):

buildscript {
    ext {
        kotlinVersion = '1.2.71'
        springBootVersion = '2.1.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-noarg:${kotlinVersion}")
    }
}

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.3.10"
    id "org.jetbrains.kotlin.plugin.spring" version "1.3.10"
    id "org.jetbrains.kotlin.plugin.jpa" version "1.3.10"
    id "org.springframework.boot" version "2.1.0.RELEASE"
    id "io.spring.dependency-management" version "1.0.6.RELEASE"
}

sourceCompatibility = 1.8
compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }
}

repositories {
    mavenCentral()
}


dependencies {
    implementation('org.springframework.boot:spring-boot-starter-data-jpa')
    implementation('org.springframework.boot:spring-boot-starter-web')
  implementation('org.springframework.boot:spring-boot-starter-mail')
    implementation('com.fasterxml.jackson.module:jackson-module-kotlin')
    implementation('org.flywaydb:flyway-core')
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("javax.mail:mail:1.5.0-b01")
    implementation(project(':myproject-ui'))
    runtimeOnly('org.postgresql:postgresql')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

jar是构建的,当我启动jar并转到localhost:8080时,应用程序的UI出现 . 好的开始 . 但是,如果我使用UI中定义的任何路由(例如:localhost:8080 / user / someid)转到应用程序,我会找不到404 . 当正常导航到角度应用程序时,这不是问题,应用程序按预期工作 .

我究竟做错了什么?