0

I have a Google App Engine project that needs to be build using java 1.8. When the build is complete I need to run the web application but using Java 1.7.

This works fine from eclipse where I am currently building using java 1.8 and then I can configure the run configuration to use JRE 1.7 when running:

enter image description here

But how do I do the same from command line? At the moment I do (from command line):

mvn clean install
mvn appengine:devserver_start

When running the last command, starting the app, I get the error:

 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.

which appears to be related to the fact that I am running with java 1.8: How to deal with App Engine Devserver exception due to FormatStyle restricted class?

I guess I could write a script that does something like:

  1. Run mvn clean install
  2. Set JDK to 1.7 for current session
  3. Runs the web app (now under java 1.7)

But is there a maven way to do this in the pom.xml?

Community
  • 1
  • 1
u123
  • 15,603
  • 58
  • 186
  • 303
  • Because you don't tell us **how** you run your thing from the command line it's hard to help you –  Nov 30 '16 at 21:27

2 Answers2

1

What you need is toolchains that maven has.

There is many documentations/tutorials:

Documentation for toolchains - Maven Site

Documentation for toolchains - Mojohaus

How to appoint specific jdk version for maven to build my project

Community
  • 1
  • 1
Paweł Głowacz
  • 2,926
  • 3
  • 18
  • 25
0

You can configure the maven compiler plugin to generate target in compliance with any specific version:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.6.0</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>

Details: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

You can set the target as 1.7.

Sourabh
  • 429
  • 1
  • 4
  • 11