我有一个 Google App Engine 项目,需要使用 java 1.8 构建。构建完成后,我需要运行 Web 应用程序,但使用 Java 1.7。
这在我当前使用 java 1.8 构建的 eclipse 中工作得很好,然后我可以配置运行配置以在运行时使用 JRE 1.7:
但是我如何从命令行执行相同的操作?目前我这样做(从命令行):
mvn clean install
mvn appengine:devserver_start
运行最后一个命令并启动应用程序时,出现错误:
Error creating bean with name 'beanNameHandlerMapping' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping]: Factory method 'beanNameHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is java.lang.NoClassDefFoundError: java.time.format.FormatStyle is a restricted class. Please see the Google App Engine developer's guide for more details.
这似乎与我使用 java 1.8 运行有关: How to deal with App Engine Devserver exception due to FormatStyle restricted class?
我想我可以编写一个脚本来执行以下操作:
- 运行mvn clean install
- 将当前 session 的 JDK 设置为 1.7
- 运行网络应用程序(现在使用 java 1.7)
但是有没有一种 Maven 方法可以在 pom.xml 中执行此操作?
最佳答案
您需要的是 toolchains那个专家有。
有很多文档/教程:
Documentation for toolchains - Maven Site
Documentation for toolchains - Mojohaus
How to appoint specific jdk version for maven to build my project
关于java - 使用java 1.8构建maven项目但使用java 1.7运行它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40898113/