美文网首页
springboot入门(2)

springboot入门(2)

作者: mxjsxz | 来源:发表于2018-06-03 22:19 被阅读0次

springboot入门(2) ——配置    

构建springboot项目,使用idea,new->Srping Initializr,根据需求选择,最后点击finish,完成项目创建。目录如下

1、pom.xml

springboot提供了很多关于starter的依赖,spring-boot-starter是Spring Boot的核心启动器,包含了自动配置、日志和YAML 。在pom中均以spring-boot-starter-开头。如在pom中增加依赖spring-boot-starter-data-jpa,即JPA(Java Persistence API),包括spring-data-jpa、spring-orm、Hibernate;spring-boot-starter-jdbc,即引入jdbc。

这种模块化的依赖配置,简化了maven的配置,引入一个模块,就能把相应的所有的依赖都引入进来。(参考13. Build systems

2、application.properties

构建springboot项目后,会在resources目录下面生成一个application.properties配置文件。springboot默认的启动端口是8080,我们可以在配置文件增加

    server.port=8081

    server.context-path=/hello

则在启动时会改成8081,访问路径ip:8081/hello。

(当然springboot支持自定义配置,更多参考Spring Boot Reference Guide

相关文章

网友评论

      本文标题:springboot入门(2)

      本文链接:https://www.haomeiwen.com/subject/gxussftx.html