

Table of Contents
Key Points Of Spring boot java 9 examples:
- Make sure that
Java 9properly install in your computer, To check java 9 version using the following command- Check
java -version - Check
javac -version
- Check
- Make sure that
IDEthat you are using supportingjava 9version - Java 9 is properly configured with IDE
Project Structure

Spring boot java 9 example – project
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>spring-boot-example</groupId>
<artifactId>spring-boot-java-9-example</artifactId>
<description>Spring boot java 9 example</description>
<version>1.0-SNAPSHOT</version>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<properties>
<java.version>9</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.9</source> <!-- java 9 compiler !-->
<target>1.9</target>
<jdkToolchain>
<version>9</version>
</jdkToolchain>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId> <!-- maven plugin for java 9 computer !-->
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>module-info.java
module spring.boot.demos {
requires java.logging;
requires spring.boot.autoconfigure;
requires spring.web;
requires spring.context;
requires spring.boot;
}SpringBootConfig
package com.javadeveloperzone;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* Created by JavaDeveloperZone on 19-07-2017.
*/
@SpringBootApplication
@ComponentScan // Using a root package also allows the @ComponentScan annotation to be used without needing to specify a basePackage attribute
public class SpringBootConfig {
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootConfig.class, args); // it wil start application
}
}
IndexController
package com.javadeveloperzone.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by Java Developer Zone on 19-07-2017.
*/
@RestController
public class IndexController {
@RequestMapping("/getJavaVersion")
public String index() {
return System.getProperty("java.version");
}
}
Package Application :
mvn install
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building spring-boot-java-9-example 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ spring-boot-java-9-example --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ spring-boot-java-9-example --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ spring-boot-java-9-example --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory F:\extrawork\spring-boot\spring-boot-java-9-example\src\test\resour ces [INFO] [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ spring-boot-java-9-example --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ spring-boot-java-9-example --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ spring-boot-java-9-example --- [INFO] [INFO] --- spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) @ spring-boot-java-9-example --- [INFO] [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ spring-boot-java-9-example --- [INFO] Installing F:\extrawork\spring-boot\spring-boot-java-9-example\target\spring-boot-java-9-example-1.0-SNAPSHOT.jar to C:\Users\Lenovo\.m2\repository\spring-boot-example\spring-boot-java-9-example\1.0-SNAPSHOT\spring-boot-java-9-example-1.0-SNAPSHOT.jar [INFO] Installing F:\extrawork\spring-boot\spring-boot-java-9-example\pom.xml to C:\Users\Lenovo\.m2\repository\spring-boot-example\spring-boot-java-9-example\1.0-SNAPSHOT\spring-boot-java-9-example-1.0-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 39.988 s [INFO] Finished at: 2017-11-24T23:54:16+05:30 [INFO] Final Memory: 21M/232M [INFO] ------------------------------------------------------------------------
Run Application
java -jar target/spring-boot-java-9-example-1.0-SNAPSHOT.jar
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.4.RELEASE) 2017-11-24 23:58:35.455 INFO 29300 --- [ main] com.javadeveloperzone.SpringBootConfig : Starting SpringBootConfig v1.0-SNAPSHOT on Mahesh with PID 29300 (F:\extrawork\spring-boot\spring-boot-java-9-example\t arget\spring-boot-java-9-example-1.0-SNAPSHOT.jar started by Lenovo in F:\extrawork\spring-boot\spring-boot-ja va-9-example) 2017-11-24 23:58:35.472 INFO 29300 --- [ main] com.javadeveloperzone.SpringBootConfig : No active profile set, falling back to default profiles: default 2017-11-24 23:58:35.728 INFO 29300 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshin g org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@74e52303: startup da te [Fri Nov 24 23:58:35 IST 2017]; root of context hierarchy
Output:

Spring boot java 9 example – output
References:
Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.
