Write in the front, each java program development, need to prepare the corresponding development tools and java running environment. The development tool used here is: idea64, the java environment used is jdk1.8, and the maven version used is:
1 create project through idea
In the menu bar of idea tool, find the File button and operate as follows: File new project, click Project Enter the create project interface.
In the New Project panel, select Spring Initializr, and select the installed JDK in the Project SDK on the right. The version 1.8.0_isused here. Select Default in the selection box below, and click Next to enter the Next operation.
Enter the Group Name of the project in the Group and the project Name in the Artifact. Do not move the contents of the Name and Package below.
Next, select the Spring Boot version, 2.24, the selection interface of configuration project dependency (project dependency is the third-party jar package resources needed during project operation). Select Web on the left and Spring Web on the right. Click next to go to the next step.
Finally, click Finish to complete the creation of the program.
Project created successfully.
2 start the created program
Under src, find the spring bootdemo application file (this is the main boot class of the Spring Boot project). Right click the file or file, and click Run "spring bootdemo application" in the pop-up window to start the newly created Spring Boot program.
In Console, the following appears, indicating that the program is started successfully.
2020-02-01 18:33:24.306 INFO 9136 --- [ main] c.z.s.SpringbootdemoApplication : Starting SpringbootdemoApplication on WIN-KOCRS5VVCHQ with PID 9136 (D:\workspace\java5\springbootdemo\target\classes started by Administrator in D:\workspace\java5\springbootdemo) 2020-02-01 18:33:24.317 INFO 9136 --- [ main] c.z.s.SpringbootdemoApplication : No active profile set, falling back to default profiles: default 2020-02-01 18:33:25.391 INFO 9136 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2020-02-01 18:33:25.407 INFO 9136 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2020-02-01 18:33:25.407 INFO 9136 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30] 2020-02-01 18:33:25.511 INFO 9136 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2020-02-01 18:33:25.511 INFO 9136 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1090 ms 2020-02-01 18:33:25.713 INFO 9136 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2020-02-01 18:33:25.837 INFO 9136 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2020-02-01 18:33:25.839 INFO 9136 --- [ main] c.z.s.SpringbootdemoApplication : Started SpringbootdemoApplication in 2.337 seconds (JVM running for 6.919)
The default port for program startup is 8080, and the usage time is 2.337 seconds.
3 Access Project through browser
Open the browser, input: http://localhost:8080 /, and the following interface will appear. The newly created Spring Boot program can be successfully requested.
4 concluding remarks
The appearance of Spring Boot has lowered the threshold of java web programming. Later, I will introduce how to write an interface, how to connect the database, and how to query the data content. Thank you for reading and welcome to pay attention.