Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
How to deploy Spring boot and Angular application as single war file?

I want to deploy spring boot and angular application as a single war file. I have tried doing it as below,

Created a build.gradle file in angular application

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'
}

Added the following to the build.gradle file in spring boot project,

implementation(project(':angularProject')

Added the following to settings.gradle file in spring boot project,

include ':angularProject'
project(':angularProject').projectDir = new File('../angularProject')

When I build the spring boot project, I could see the angularProject in the spring boot project location but I want it to automatically display in the static folder in the resources folder in the spring boot project. Am I missing anything? Any help is much appreciated.

Edit:

Now, when building the project I'm getting the following error

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

Thank you.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Use Maven plug-in frontend-maven-plugin https://github.com/eirslett/frontend-maven-plugin . See https://marco.dev/deploy-java-angular-one

In case you use Gralde, use this plug-in https://github.com/siouan/frontend-gradle-plugin . But frontend-maven-plugin is more stablity.

over 4 years ago · Santiago Trujillo Relatório

0



<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>1.10.4</version>
    <executions>
        <execution>
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
            <configuration>
                <nodeVersion>v14.15.1</nodeVersion>
                <npmVersion>6.14.8</npmVersion>
            </configuration>
        </execution>
        <execution>
            <id>npm</id>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>install --cache</arguments>
            </configuration>
        </execution>
        <execution>
            <id>npm install</id>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>install</arguments>
            </configuration>
        </execution>
        <execution>
            <id>cli build prod</id>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>run build-prod</arguments>
            </configuration>
            <phase>generate-resources</phase>
        </execution>
    </executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <warSourceDirectory>target/classes/static</warSourceDirectory>
    <webResources>
        <resource>
            <directory>src/main/webapp</directory>
            <includes>
                <include>WEB-INF/**</include>
                <include>js/**</include>
                <include>img/**</include>
                <include>css/**</include>
                <include>index.html</include>
                <include>legal.html</include>
                <include>privacyPolicy.html</include>
            </includes>
        </resource>
    </webResources>
</configuration>
</plugin>
        

on frontend-maven-plugin, we are building angular and on maven-war-plugin, we include angular build file into the war file or exclude some files

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda