First, open the URL https://start.spring.io/ into springboot official website, according to their actual situation to select the desired components, click Generate.
Second, the import maven project, but pom.xml reported Line1 unknown error checked and found to be version,
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
Into <version> 2.0.0.RELEASE </ version> properties will not be given or added in pom.xml file version number maven jar widget, as follows:
<Maven-jar-plugin.version> 3.1.1 </maven-jar-plugin.version> problems caused by upgrading to the 2.1.5.RELEASE caused 3.1.2.
You can find errors have disappeared
Three, springboot generated by default boot entry
package com.bootdemo.bootdemo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class BootdemoApplication { public static void main(String[] args) { SpringApplication.run(BootdemoApplication.class, args); } }
Pom modify the types of projects
<groupId>com.bootdemo</groupId> <artifactId>bootdemo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <name>bootdemo</name> <Description> microService total project </ description>
After you create a sub-project module, there will be created in pom.xml
<modules> <module>spring-application</module> </modules>
Add startup class, add pom-dependent
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>
Fourth, start the boot project, the default port 8080, to get access to the following information
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Sun Jun 23 23:37:59 CST 2019 There was an unexpected error (type=Not Found, status=404). No message available
Modify the startup class, SpringApplicationBuilder way, change the start port 8090,
server.port = 0 represents a random using the operating system to a free port, general test unit time
//SpringApplication.run(BootdemoApplication.class, args); new SpringApplicationBuilder(BootdemoApplication.class)//Fluent Api .properties("server.port=8090") .run(args);
If using SpringApplication achieve, the more trouble for
SpringApplication springApplication = new SpringApplication(BootdemoApplication.class); HashMap<String, Object> propertis = new LinkedHashMap<>(); propertis.put("server.port", 8090); springApplication.setDefaultProperties(propertis); springApplication.run(args);