我想从启动1.4.3升级到spring boot 1.5.6。 我使用spring初始化程序创建了一个简单的Web项目,并添加了一个简单的Controller类。我的pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
RestApplication.java
package com.djcodes.testing.rest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class RestApplication {
public static void main(String[] args) {
SpringApplication.run(RestApplication.class, args);
}
}
EmployeeController.java
package com.djcodes.testing.rest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/employee")
public class EmployeeController {
@RequestMapping(method = { RequestMethod.GET }, value ="/welcome")
public String welcome() {
return "Welcome to employee controller";
}
}
当我尝试启动它时,请先启动并构建
$ mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demo-rest-api 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.5.6.RELEASE:run (default-cli) > test-compile @ demo-rest-api >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ demo-rest-api ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ demo-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/dj/Github/test-frameworks-tools/demo-rest-api/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ demo-rest-api ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.5.6.RELEASE:run (default-cli) < test-compile @ demo-rest-api <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.6.RELEASE:run (default-cli) @ demo-rest-api ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2017-08-20 16:53:09.047 INFO 7690 --- [ main] c.djcodes.testing.rest.RestApplication : Starting RestApplication on lenovo with PID 7690 (/home/dj/Github/test-frameworks-tools/demo-rest-api/target/classes started by dj in /home/dj/Github/test-frameworks-tools/demo-rest-api)
2017-08-20 16:53:09.051 INFO 7690 --- [ main] c.djcodes.testing.rest.RestApplication : No active profile set, falling back to default profiles: default
2017-08-20 16:53:09.099 INFO 7690 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@72458578: startup date [Sun Aug 20 16:53:09 IST 2017]; root of context hierarchy
2017-08-20 16:53:09.762 INFO 7690 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-08-20 16:53:09.772 INFO 7690 --- [ main] c.djcodes.testing.rest.RestApplication : Started RestApplication in 0.966 seconds (JVM running for 4.05)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.740 s
[INFO] Finished at: 2017-08-20T16:53:09+05:30
[INFO] Final Memory: 28M/275M
[INFO] ------------------------------------------------------------------------
2017-08-20 16:53:09.942 INFO 7690 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@72458578: startup date [Sun Aug 20 16:53:09 IST 2017]; root of context hierarchy
2017-08-20 16:53:09.943 INFO 7690 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
spring-boot 1.5.6有什么变化吗?以上工作正常,1.4.3
谢谢
答案 0 :(得分:0)
好像是Spring Boot版本问题。使用1.5.3.RELASE