The creation of the springboot project under the idea, the configuration information of the database and the whole process of verification

After opening the idea, select the corresponding option on the left

 After clicking Next, fill in the customized information. It should be noted that maven should be selected for Type, which may be other by default, and Java version should also be selected, and then click Next

 Then enter the interface for installing the plug-in. First of all, my project is a web project, so with a spring web, the project can run normally, because my project still needs to connect to the database, so there is also a JDBC API to connect to the database, mybatis framwork It is a plug-in to connect to the database, very easy to use, MySQL driver is the driver to connect to the database. then click next

Then select the path where the project is stored, click Finish, and wait for the initialization of the project

 

After entering, first click File-setting, select maven, change to the configured maven, and refresh maven in pom.xml after apply

 

Since we have introduced the dependency of the database, we need to configure the parameters of the database, change the application.properties to the suffix yml, and write the basic information. Among them, context-path: / defines the starting path of file access as the root directory, without adding the project name

 server:
  port: 8080
  servlet:
    context-path: /
spring:
  datasource:
    username: root
    password: 123456
    url: jdbc:mysql://127.0.0.1:3306/activiti?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC&nullCatalogMeansCurrent=true
    driver-class-name: com.mysql.cj.jdbc.Driver

 

Write a test interface to test access

Create a Java class of HelloController as shown in the figure and write the code. Among them, @RestController is equivalent to the combination of @Controller and @ResponseBody

package com.mz.activiti7_springboot_workflow.controller;

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

@RestController
public class HelloController {

    @RequestMapping(value = "/hello" ,method = RequestMethod.GET)
    public String hello(){
        return "hello world!";
    }
}

Visit localhost:8080/hello

The test is successful, and the spring boot project test is completed

 

Guess you like

Origin blog.csdn.net/romantic6666/article/details/128447549