简体   繁体   English

谷歌云应用引擎 Spring 部署错误

[英]Google cloud App engine Spring deploy error

Im trying to deploy a springboot rest api to google cloud's app engine, following this recent tutorial: https://medium.com/@smccartney09/deploy-a-spring-boot-api-to-gcp-app-engine-722198bab4d4and Im trying to deploy a springboot rest api to google cloud's app engine, following this recent tutorial: https://medium.com/@smccartney09/deploy-a-spring-boot-api-to-gcp-app-engine-722198bab4d4and

However i'm getting this error:但是我收到了这个错误:

org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

The app runs normally in localhost, from what I can see trying to debug, on localhost springboot launches a tomcat web server, and it doesn't in the logs form google app run deployment.该应用程序在本地主机中正常运行,从我所看到的尝试调试来看,在本地主机上 springboot 启动了 tomcat web 服务器,并且它不在谷歌应用程序运行部署的日志中。 Does this mean I have to use google's web server instead of tomcat?这是否意味着我必须使用谷歌的 web 服务器而不是 tomcat? i'm really lost as to what i'm doing wrong right now.我真的很迷茫,因为我现在做错了什么。

POM xml: POM xml:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.1</version>
        <relativePath/>
    </parent>
    <groupId>com.owl</groupId>
    <artifactId>owl-server</artifactId>
    <version>0.0</version>
    <name>owl-server</name>
    <description>owl backend server</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.4</version>
        </dependency>
        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.3.9</version>
        </dependency>
        <dependency>
            <groupId>io.vavr</groupId>
            <artifactId>vavr</artifactId>
            <version>0.10.3</version>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
            <version>1.2.8.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

main:主要的:

@SpringBootApplication
@EnableCaching
public class OwlServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(OwlServerApplication.class, args);

    }

Ok, so after a lot of reading i think it might be because google app engine doesnt support tomcat as a webserver, and instead only supports jetty?好的,所以经过大量阅读后,我认为这可能是因为谷歌应用引擎不支持 tomcat 作为网络服务器,而只支持码头? so i tried the following:所以我尝试了以下方法:

added to pom xml:添加到 pom xml:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

but this does nothing, same exact error.但这什么也没做,同样的错误。 I then tried to add jetty as well, which runs locally great as a jetty web server, but gives the same error on app engine.然后我也尝试添加码头,它在本地运行得很好,作为码头 web 服务器,但在应用程序引擎上给出了相同的错误。 So we know the error is due to google app engine not supporting tomcat or jetty, but what do i use now?所以我们知道错误是由于谷歌应用引擎不支持 tomcat 或码头,但我现在用什么? Anyone have any idea on whats going wrong?有人知道出了什么问题吗?

So after a lot of debugging, the problem here lies in spring security.所以经过大量调试,这里的问题出在spring安全性上。 If you have a class that extends WebSecurityConfigurerAdapter, spring will automatically attempt to use apply it to the embedded tomcat web server. If you have a class that extends WebSecurityConfigurerAdapter, spring will automatically attempt to use apply it to the embedded tomcat web server. Which is not supported on google app engine, which broke it.谷歌应用引擎不支持它,这打破了它。 Just remove the class and the app will work.只需删除 class 即可运行该应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用应用引擎部署本地主机上的谷歌云应用引擎和 Spring Boot 错误 - google cloud app engine and spring boot bug on localhost deploy with app engine 如何将Spring Boot(1.3.6)或任何Spring Boot项目(连接到云数据库)部署到Google App Engine? - How to deploy Spring Boot (1.3.6) or any Spring Boot project (connection to cloud database) to Google App Engine? 在Google App Engine中部署Spring + Hibernate + Maven + Google Cloud SQL应用程序 - Deploy Spring + Hibernate + Maven + Google Cloud SQL application in Google App Engine Spring 在 Google Cloud App Engine 上启动托管 - Spring Boot hosting on Google Cloud App Engine Google App Engine Maven Spring项目无法部署 - Google App Engine maven spring project not able to deploy GAE中的Spring Hibernate错误(Google App Engine) - Spring Hibernate error in GAE (Google App Engine) 使用Spring MVC部署App引擎 - App engine deploy with spring MVC 在 Google Cloud App Engine 上构建 Spring Boot 应用程序的触发器 - Build trigger for Spring Boot application on Google Cloud App Engine 将Spring MVC Rest服务与Google Cloud App Engine和Cloud MySQL集成 - Integrating Spring MVC Rest service with google cloud app engine and cloud mysql Java Spring和Google App Engine - Java Spring and Google App Engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM