org.springframework.boot
spring-boot-starter-freemarker
org.springframework.boot
spring-boot-devtools
true
org.springframework.boot
spring-boot-maven-plugin
true
3、创建SpringBoot启动程序
注意:springBoot必须放在Controller包的顶层
package com.jmxk;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBoot_Start {
public static void main(String[] args) {
SpringApplication.run(SpringBoot_Start.class, args);
}
}
4、创建HTTP请求连接类
package com.jmxk.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//@RestController = @Conctroller + @ResponseBody
@RestController
public class HelloController {
@RequestMapping(“/helloIndex”)
public String HelloIndex() {
return “欢迎使用springBoot2.0!”;
}
}
5、启动SpringBoot程序
控制信息出现Spring图标样式并且程序一直在运行没报错则表示启动成功!
. ____ _ __ _ _
/\ / _’ __ _ () __ __ _ \ \ \ \
( ( )___ | '_ | '| | ’ / _` | \ \ \ \
\/ _)| |)| | | | | || (| | ) ) ) )
’ || .__|| ||| |__, | / / / /
=|_|======|/=////
:: Spring Boot :: (v2.1.1.RELEASE)
2019-08-15 11:25:58.306 INFO 15224 — [ restartedMain] com.jmxk.SpringBoot_Start : Starting SpringBoot_Start on DESKTOP-A9VMB8N with PID 15224 (F:\Eclipse-WorkSpace\JavaEE\SpringBoot_Start\target\classes started by com in F:\Eclipse-WorkSpace\JavaEE\SpringBoot_Start)
2019-08-15 11:25:58.309 INFO 15224 — [ restartedMain] com.jmxk.SpringBoot_Start : No active profile set, falling back to default profiles: default
2019-08-15 11:25:58.357 INFO 15224 — [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set ‘spring.devtools.add-properties’ to ‘false’ to disable
2019-08-15 11:25:58.357 INFO 15224 — [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the ‘logging.level.web’ property to ‘DEBUG’
2019-08-15 11:25:59.419 INFO 15224 — [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-08-15 11:25:59.441 INFO 15224 — [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-15 11:25:59.441 INFO 15224 — [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2019-08-15 11:25:59.449 INFO 15224 — [ restartedMain] 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\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.8/bin/…/jre/bin/server;C:/Program Files/Java/jdk1.8/bin/…/jre/bin;C:/Program Files/Java/jdk1.8/bin/…/jre/lib/amd64;C:\Python27;C:\Python27\Scripts;C:\Python\Python37\Scripts;C:\Python\Python37;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Java\jdk1.8\bin;MYSQL_HOME%\bin;D:\Maven\apache-maven-3.6.0\bin;D:\Node\nodejs;C:\ProgramData\chocolatey\bin;C:\Program Files\TortoiseGit\bin;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\TXsoft\Git\cmd;C:\Users\com\AppData\Local\Microsoft\WindowsApps;D:\Node\nodejs\node_global;;D:\JetBrains\IntelliJ IDEA 2019.1\bin;;D:\JetBrains\WebStorm 2019.1\bin;;C:\WINDOWS\system32;;.]
2019-08-15 11:25:59.522 INFO 15224 — [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-15 11:25:59.523 INFO 15224 — [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1165 ms
2019-08-15 11:25:59.725 INFO 15224 — [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService ‘applicationTaskExecutor’
2019-08-15 11:25:59.806 INFO 15224 — [ restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2019-08-15 11:25:59.905 INFO 15224 — [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-08-15 11:25:59.954 INFO 15224 — [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ‘’
2019-08-15 11:25:59.958 INFO 15224 — [ restartedMain] com.jmxk.SpringBoot_Start : Started SpringBoot_Start in 1.936 seconds (JVM running for 3.838)
6、浏览器访问 http://localhost:8080/helloIndex
springboot不需要输入项目名称,输入格式是本地IP地址+端口号+请求路径
本地IP地址:localhost或者127.0.0.1
端口号默认:8080
请求路径为Controller类中注解@RequestMapping(“/helloIndex”)自定义的值
7、SpringBoot整合fremarker,在pom.xml添加配置信息(之前的pom.xml中已经有了)
org.springframework.boot
spring-boot-starter-freemarker
8、在resources下创建一个文件夹templates,在文件夹下创建一个ftl的文件
Spring整合FreeMarker!
${map.id}
${map.name}
${map.sex}
${map.age}
9、新建一个Controller类
最后
在面试前我整理归纳了一些面试学习资料,文中结合我的朋友同学面试美团滴滴这类大厂的资料及案例
由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
大家看完有什么不懂的可以在下方留言讨论也可以关注。
觉得文章对你有帮助的话记得关注我点个赞支持一下!
9、新建一个Controller类
最后
在面试前我整理归纳了一些面试学习资料,文中结合我的朋友同学面试美团滴滴这类大厂的资料及案例
[外链图片转存中…(img-mOD9BxLT-1716573614708)]
[外链图片转存中…(img-DxWGOH4N-1716573614708)]
由于篇幅限制,文档的详解资料太全面,细节内容太多,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
大家看完有什么不懂的可以在下方留言讨论也可以关注。
觉得文章对你有帮助的话记得关注我点个赞支持一下!