Getting started with JAVA basics Use IDEA to create maven, springboot, springboot springmvc projects

1. Install idea

IDEA official website https://www.jetbrains.com/zh-cn/products/#type=ide
Insert picture description here

IDEA cracking tutorial: https://tech.souyunku.com/?p=30970

Idea settings

Code hints are not case sensitive

Filesettings enter the setting interface
Editor-->General-->code completions

Enter the interface in the figure, do not select Match case, and then click OK
Insert picture description here

Show doc when mouse is moved in

Insert picture description here
Some computers are as shown below
Insert picture description here

The shortcut keys are the same as eclipse

Insert picture description here

Global settings configuration maven

File→Settings, enter maven in the input box,
Insert picture description here

2. Create a maven project

Insert picture description here

Step 1: Filenew Project creates a project named idea_maven,

Insert picture description here

Step 2: First select maven, then select Create from archtype, then select

org.apache.maven.archtypes:maven-archtype-quickstart
Insert picture description here

Step 3: Enter com.tedu.01maven

Insert picture description here
Step 4: Choose the location of your own local warehouse
Insert picture description here

Finish the new creation is complete, check whether there is an App class in src, if not, please see step 5

Insert picture description here

Step 5: Set up the sources directory

If you don’t set the sources directory, you cannot create a class under the package.
Select the project and right-click open module settings to open the settings window. First select modulessourcesjava on the left and right-click sources.
Insert picture description here

Final test: Open App.java, right-click run, and output the program running results in the run window.

Insert picture description here




2. Create a springboot project

Step 1: File→new→project...

Insert picture description here

Step 2: Enter the domain name + project name and select your JDK version number

Insert picture description here

Step 3: Select Web→Spring Web→Select the dependent version

Insert picture description here

Step 4: View the project name and project path

Insert picture description here
Insert picture description here

Step 5: Created

Insert picture description here

Step 6: If the dependency download fails, the solution:

Insert picture description here

Step 7: Test whether it is running

Create a new controller package and test the Testcontroller class
Insert picture description here

package com.tedu.idea03springboot.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    
    
    @RequestMapping("/test")
    public String test(){
    
    
        return "ok";
    }
}

Open the main class Run As to run:
http://localhost:8080/test
Insert picture description here

Problems encountered:

1. There is no Spring Initializr in IDEA, indicating that your version is community-run, you can go to the professional version or install plug-ins


Open opens a springboot project, and idea uses its own download 3.3.9. Some computers do not work.
Solution
1. Use idea to create an ordinary maven project and set maven to 3.6.3
Insert picture description here

2. Copy the project generated by start.spring.io.
Some computers report errors, you can refer to the following figure to solve
Insert picture description here
Insert picture description here

2. Just turn off and reopen.
Create a normal maven project, check the location of the default maven warehouse, and copy all the jars of the machine.
The latest version of idea maven warehouse can only be in the default directory
3 of the c drive , and the package name is the same




Import a created maven project yourself

Download the DbDemo project, unzip it into the IDEA workspace,
then change the folder name to, open pom.xml, and modify the project name in the pom
Insert picture description here

Open IDEA→OPEN, select the project you want to import:

Insert picture description here

Guess you like

Origin blog.csdn.net/QQ1043051018/article/details/112881510