Python中文网

一个关于 编程问题的解答网站.

有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java通过cloudbuild的应用引擎部署获得404

我有一个spring boot gradle项目,我正在eclipse中开发,并正在向云存储库推进。我配置了一个云构建触发器来启动gradle构建并部署到应用程序引擎(标准)。根据构建日志,每一步都是成功的,但当我点击URL时,我得到了404,不知道为什么

当我在笔记本电脑上进行gradle appengineDeploy时,我能够部署到应用程序引擎,我的服务就会启动。这让我相信我的cloudbuild。yaml文件不正确

cloudbuild。亚马尔

steps:
  - name: 'gcr.io/cloud-builders/gradle'
    args: ['build']
  - name: 'gcr.io/cloud-builders/gcloud'
    args: ['app', 'deploy', 'src/main/webapp/WEB-INF/appengine-web.xml']
timeout: '1600s'

src/main/webapp/WEB-INF/appengine-WEB。xml

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>my_project_id</application>
  <version>1</version>
  <threadsafe>true</threadsafe>
  <runtime>java8</runtime>
  <system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/classes/logging.properties"/>
  </system-properties>    
</appengine-web-app>

建造。格拉德尔

buildscript {
    ext {
        springBootVersion = '2.0.6.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.+' 
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'war'

group = 'my-group'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compileOnly('javax.servlet:javax.servlet-api:3.1.0')
    compileOnly('org.slf4j:jul-to-slf4j')
    implementation('org.springframework.boot:spring-boot-starter-data-jpa')
    implementation('org.springframework.cloud:spring-cloud-gcp-starter-sql-mysql:1.0.0.RELEASE')
    implementation('org.springframework.boot:spring-boot-starter-web') {
       exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
    }
    implementation('com.google.appengine:appengine-api-1.0-sdk:+')
}

建筑日志

Step #0: BUILD SUCCESSFUL in 53s
Step #0: 4 actionable tasks: 4 executed
Finished Step #0
Starting Step #1
Step #1: Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1: Services to deploy:
Step #1: 
Step #1: descriptor: [/workspace/src/main/webapp/WEB-INF/appengine-web.xml]
Step #1: source: [/workspace/src/main/webapp]
Step #1: target project: [dev-poc-220521]
Step #1: target service: [default]
Step #1: target version: [20181111t040050]
Step #1: target url: [https://dev-poc-220521.appspot.com]
Step #1: 
Step #1: 
Step #1: Do you want to continue (Y/n)? 
Step #1: Beginning deployment of service [default]...
Step #1: #============================================================#
Step #1: #= Uploading 5 files to Google Cloud Storage =#
Step #1: #============================================================#
Step #1: File upload done.
Step #1: Updating service [default]...
Step #1: .......................................................done.
Step #1: Setting traffic split for service [default]...
Step #1: ........done.
Step #1: Deployed service [default] to [https://dev-poc-220521.appspot.com]
Step #1: 
Step #1: You can stream logs from the command line by running:
Step #1: $ gcloud app logs tail -s default
Step #1: 
Step #1: To view your application in the web browser run:
Step #1: $ gcloud app browse --project=dev-poc-220521
Finished Step #1

共 (1) 个答案

  1. # 1 楼答案

    你检查了server.port=<some_port_number>application.properties的端口设置了吗?我也遇到了同样的问题,当我删除自定义端口号时,它会按预期工作