I've upgraded a working Spring Boot 1.4 web app to 2.0.5 I followed the migration guide and worked through the various compiler errors. When running the app via IntelliJ I now only get
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE)
Process finished with exit code 0
Tried running with debug output, nothing additional
It seems like it's not starting an embedded servlet container, so I after looking at change logs for Spring 2.0 I added the following to the config
spring.main.web-application-type=servlet
Read some more and checked that
compile('org.springframework.boot:spring-boot-starter-web')
is in my build.grade, which it is. It's also pulling in as a dependency
spring-boot-starter-tomcat
I then tried creating and use a simple test Main class
@RestController
@SpringBootApplication
public class TestApp {
@RequestMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(TestApp.class, args);
}
}
but still "exit code 0".
I also tried removing everything from my application.properties when using the class above.
Given there are no errors, I'm not sure where to go from here.
There are two ways you can fix this probelm..
Approach 1:
@SpringBootApplication
public class TestApp {
@GetMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(TestApp.class, args);
}
}
Approach 2
STEP 1: Your main class will have only main method:
@SpringBootApplication
public class TestApp {
public static void main(String[] args) throws Exception {
SpringApplication.run(TestApp.class, args);
}
}
STEP 2: Create TestController and put your methods here like below:
@RestController
public class TestController {
@GetMapping("/")
String home() {
return "Hello World!";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.