初學spring boot,按照網上教程,用eclipse +maven+spring boot 創建了一個項目,controller非常簡單,代碼如下:
package com.example.demo.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class demoController
{
@ResponseBody
@RequestMapping("demo")
public String demo()
{
return "hello world;hello spring boot";
}
}
運行後,console出現以下訊息:
2019-07-05 05:08:58.880 INFO 10420 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on LAPTOP-FAS0SHLM with PID 10420 (C:\Users\yueho\eclipse-workspace\demo\target\classes started by yueho in C:\Users\yueho\eclipse-workspace\demo)
2019-07-05 05:08:58.886 INFO 10420 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2019-07-05 05:09:00.430 INFO 10420 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-07-05 05:09:00.470 INFO 10420 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-07-05 05:09:00.470 INFO 10420 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2019-07-05 05:09:00.480 INFO 10420 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_92\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_92/bin/server;C:/Program Files/Java/jre1.8.0_92/bin;C:/Program Files/Java/jre1.8.0_92/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_92\bin;C:\Program Files\Java\jdk1.8.0_92\jre\bin;C:\Users\yueho\AppData\Local\Microsoft\WindowsApps;;C:\Users\yueho\OneDrive\Desktop;;.]
2019-07-05 05:09:00.690 INFO 10420 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-07-05 05:09:00.690 INFO 10420 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1732 ms
2019-07-05 05:09:01.029 INFO 10420 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-07-05 05:09:01.288 INFO 10420 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-07-05 05:09:01.294 INFO 10420 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 2.946 seconds (JVM running for 4.484)
但我在eclipse自帶瀏覽器輸入:http://localhost:8080/,卻出現以下訊息:
The webpage cannot be found
請問問題出在哪裏?
我用的tomcat是maven內崁的,請問如何配置?