For beginners of springboot, some problems encountered in the process of learning are recorded.

  1. First, configure the Maven environment and local repository





    Then go to the settings. XML configuration file in the Maven installation directory conf folder and open the file with Notepadd++.
  • Configure the local repository to point to the local repository you created, as shown in the figure

  • To fix the JDK version at 1.8, insert the following code under the tag
<profile> < ID > JDK-1.8 </ ID > <activation> <activeByDefault>true</activeByDefault> < JDK >1.8</ JDK > </activation> Piler < properties > < maven.com. Source > 1.8 < / maven.com piler source > < maven.com piler. Target > 1.8 < / maven.com piler. Target > The < maven.compiler.com pilerVersion > 1.8 < / maven.compiler.com pilerVersion > < / properties > < / profile >Copy the code
  • Maven has changed the central warehouse to the warehouse address of Ali Cloud. If you don’t change it, the download speed of JAR package is very slow. I suggest you change it. Insert the following code into the tag
<! <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>Copy the code

2. Create a New Maven project in Eclipse, File — >New — >Other… — > Find Maven — >Maven Project — >Next

  • Open the SpringBoot project and write the following code under POM.xml to inherit the parent project and dependency injection.
	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
	</parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
Copy the code
  • Create a File named application.pproperties under SRC /main/resource. Right-click SRC /main/resource – >New – >File – > rename. Write the following code in application.pproperties
server.port=8081
Copy the code

Change the port to 8081 to avoid port occupation when Tomcat is running

  • Then right-click Project – >Maben – >Update Project to Update the Maven Project.
  • Then create a package and class in SRC /main/ Java, such as application.java under com.xdr
package com.xdr.spring; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; Public class Application {public static void public static void public static void public static void public static void public static void Main (String[] args) {system.out.println (" start springboot"); SpringApplication.run(Application.class, args); }}Copy the code

Finally start the project and run out



The SpringBoot project is running successfully.