如何在以Angular 6为前端的heroku上部署spring-boot应用程序?

时间:2018-09-20 07:38:43

标签: angular spring-boot heroku npm

我想在我使用spring-boot的heroku上部署一个应用程序。但是我还需要npm来构建我的角度项目。

我的build.gradle是这样的:

buildscript {
	ext {
		springBootVersion = '2.1.0.M2'
	}
	repositories {
		mavenCentral()
		maven { url "https://repo.spring.io/snapshot" }
		maven { url "https://repo.spring.io/milestone" }
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.rahulcomputers'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
	mavenCentral()
	maven { url "https://repo.spring.io/snapshot" }
	maven { url "https://repo.spring.io/milestone" }
}


dependencies {
	compile('org.springframework.boot:spring-boot-starter-web')
	compile('org.springframework.boot:spring-boot-starter-data-jpa')
	compile('org.springframework.boot:spring-boot-starter-webflux')
	compile group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
	compile 'org.apache.commons:commons-text:1.4'
	compile group: 'org.jsoup', name: 'jsoup', version: '1.11.3'
	runtime('mysql:mysql-connector-java')
	runtime('org.postgresql:postgresql')
	testCompile('org.springframework.boot:spring-boot-starter-test')
	testCompile('io.projectreactor:reactor-test')
}

def webappDir = "$projectDir/src/main/webapp"
sourceSets {
	main {
		resources {
			srcDirs = ["$webappDir/dist", "$projectDir/src/main/resources"]
		}
	}
}
 
processResources {
	dependsOn "buildAngular"
}
  
task buildAngular(type:Exec) {
	// installAngular should be run prior to this task
	dependsOn "installAngular"
	workingDir "$webappDir"
	inputs.dir "$webappDir"	
	// Add task to the standard build group
	group = BasePlugin.BUILD_GROUP
	// ng doesn't exist as a file in windows -> ng.cmd
	if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")){
		commandLine "ng.cmd", "build"
	} else {
		commandLine "ng", "build"
	}
}
 
task installAngular(type:Exec) {
	workingDir "$webappDir"
	inputs.dir "$webappDir"
	group = BasePlugin.BUILD_GROUP
	if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")){
		commandLine "npm.cmd", "install"
	} else {
		commandLine "npm", "install"
	}
}

当我尝试在heroku上部署它时,由于npm不存在,它会产生一个构建错误,您能告诉我如何拥有npm以及Spring-Boot(带有gradle)。

0 个答案:

没有答案