The spring project is useless in the new project of the idea community version. There are generally two methods on the Internet: downloading demos from the official website and using plug-ins. Here is an example from the official website.
Spring official website demo
Spring Initializr: https://start.spring.io/
Configure and choose what you are familiar with
Project: choose to use gradle to build the project, groovy language configuration
Language: choose Java
Spring boot: choose a newer version 3.0.5
Packaging: jar
Java: Version 17 (java17 is required after Spring boot3)
Dependencies: Spring Web
After selecting, click generate to download the project zip package
Java17
Choose zulu jdk here
https://www.azul.com/downloads/?package=jdk#zulu
project run
package com.example.demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/hello")
public class DemoController {
@RequestMapping("/boot")
public String helloBoot() {
return "Hello Spring Boot!";
}
}
Browser access after running
http://localhost:8080/hello/boot
local access is fine
Modify port
application.properties
#tomcat服务默认端口
server.port=7355
Gradle package and run
Because gradle was selected when downloading the demo, gradle is used for packaging here
Click bootJar in the gradle task
部署运行
java -jar demo-0.0.1-SNAPSHOT.jar
服务器部署
nohup java -jar demo-0.0.1-SNAPSHOT.jar &
reference
https://blog.csdn.net/qq_40036754/article/details/125999709
https://juejin.cn/post/7039164020644904968
https://zhuanlan.zhihu.com/p/578972804
https://blog.csdn.net/weixin_49001740/article/details/122604111
https://blog.csdn.net/oldfish_/article/details/128172075