我有一个在GCP上运行的Spring Boot应用程序(至今已有1年),我想对其进行更新,但是当我在本地运行mvn appengine:run
时出现此错误:
[INFO] GCLOUD: INFOS: javax.servlet.ServletContext log: 2 Spring WebApplicationInitializers detected on classpath
[INFO] GCLOUD: java.lang.IllegalArgumentException: Unable to find the main class to restart
[INFO] GCLOUD: at org.springframework.util.Assert.notNull(Assert.java:198)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter.doStart(Restarter.java:277)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter.start(Restarter.java:265)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter.lambda$immediateRestart$0(Restarter.java:173)
[INFO] GCLOUD: at org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:637)
[INFO] GCLOUD: d?c. 02, 2018 4:30:20 PM com.google.appengine.api.datastore.dev.LocalDatastoreService cleanupActiveServices
[INFO] GCLOUD: INFOS: scheduler shutting down.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.255 s
[INFO] Finished at: 2018-12-02T17:30:21+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:run (default-cli) on project sample-app: Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:run failed: Non zero exit: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:run (default-cli) on project tacos-time29: Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:run failed: Non zero exit: 1
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
主类有问题。在我的pom.xm中,我定义了以下内容:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<appengine.maven.plugin>1.3.1</appengine.maven.plugin>
<!--Definition of the main class-->
<start-class>com.example.sample.Application</start-class>
</properties>
我还在spring-boot-plugin中定义了主类
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
/WEB-INF/appengine-web.xml
文件的内容是基本的:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<version>1</version>
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
</appengine-web-app>
感谢您的帮助
答案 0 :(得分:4)
我在这里找到了解决方法:https://github.com/GoogleCloudPlatform/gradle-appengine-plugin/issues/294
只需删除devtools
依赖项即可。这是一个非常奇怪的行为