How to create a Spring Boot project using IntelliJ Community Edition
Januar 26, 2023 - Lesezeit: 148 Minuten
As IntelliJ CE does not provide the Spring Bundle Plugins out of the box (Details), you can initiate the project using Spring Initializr (https://start.spring.io) for example with the following options:
- Project: Maven
- Language: Java
- Spring Boot: 2.7.8
- Group: com.yourcompany or even com.anh.hoang :)
- Artifact: fat-jar-webserver
- Description: Spring Boot Executable Jar Project
- Package name: com.anh.hoang.fat-jar-server
- Packaging: Jar
- Java: 8 for compatibility sake
- Dependencies:
- Finally Generate
Back to IntelliJ
- Extract fat-jar-server.zip
- Open > fat-jar-server/pom.xml > Open as Project
- Create new package config, web

- In package config > New > Java Class > Add new class WebConfiguration
- Content:
package com.anh.hoang.fatjarwebserver.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Configuration
public class WebConfiguration {
@Value("${customer.name}")
private String customer;
public String getCustomer() {
return customer;
}
}
- In package web > New > Java Class > Add new class CustomerResource
- Content:
package com.anh.hoang.fatjarwebserver.web;
import com.anh.hoang.fatjarwebserver.config.WebConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class CustomerResource {
@Autowired
WebConfiguration webConfiguration;
@GetMapping("/customer")
public String getCustomer(){
return webConfiguration.getCustomer();
}
}
- Remove the 2 unneeded folders for now

- Add content to resouces/application.properties
server.port=8686
customer.name=John Wayne
- As we have added Maven Plugin, we now can use Maven to clean, build and deploy the project:

- Now execute mvn clean and make sure the BUILD SUCCESS with exit code 0
- Next execute mvn install
- In case you face the following issue:
invalid target release: 17
Module fat-jar-server SDK 1.8 is not compatible with the source version 17.
Upgrade Module SDK in project settings to 17 or higher. Open project settings.
- Most probably the java version in your pom.xml is not right, so update it from
<properties>
<java.version>17</java.version>
</properties>
to
<properties>
<java.version>1.8</java.version>
</properties>
- Next is when you face the issue
cannot access org.springframework.beans.factory.annotation.Value
It could be becasue of the following error:

Well if this is the case, that means that instead of Spring Boot 2, you wet for 3.0.2 instead. This requires a higher Java version (Java 17, major release 61). So it would make sense if you can jump back to step 1 and initialize the project using a compatible Spring Boot and Java set.
- If mvn install worked as expected and the BUILD SUCCESS with exit code 0, you should be able to find a target/fat-jar-webserver-0.0.1-SNAPSHOT.jar which is our fat jar containing all the libraries needed.
- Now you can either right click on the jar file and Run or
- Ctrl+Shift+F10 to run it or
- exevute the following command from the terminal:
java -jar .\target\fat-jar-webserver-0.0.1-SNAPSHOT.jar
- The Website will then be available under:
http://localhost:8686/customer
- You can create a target/config folder and paste an application.properties file inside. Change the port and the customer name as pleased and execute java -jar .\target\fat-jar-webserver-0.0.1-SNAPSHOT.jar to notice the different configuration.

- In case you did not create the config folder for your jar file, it is still totally fine, as the jar file will turns back to the included application.properties in the package itself and use this as standard parameters to operate with.