최근에 나는 스프링 부츠를 배우고 있었다. 프레임 워크를 배우는 것은 이전에 한 일을하기 위해 사용하는 것 이상입니다. 둘이 다릅니다. 내가 사용한 경험을 말씀 드리겠습니다.
Spring Boot First, Microframework에 대해 이야기 해 봅시다. 빠른 개발은 구성이없는 것과 같습니다. 마스터의 관점에서 : Spring Boot는 많은 통합 인 프레임 워크의 프레임 워크와 동일합니다. 어떤 종속성이 충분한 지 추가하십시오. 이런 식으로, 당신은 직접 구성을 볼 수 없습니다. 구성을 사용하는 데 익숙한 개발자의 경우 방금 스프링 부팅을 사용한 개발자에게는 익숙하지 않을 수 있습니다. 그들은 아무것도 일치 할 필요가 없습니다. 그들은 구성이 보이지 않습니다. 프로젝트의 전반적인 아키텍처에 약간 익숙하지 않습니다. 게다가, 스프링 부츠에서 Thymeleaf 사용. JSP가 HelloWorld를 보여주고 Thymeleaf를 보여주기 위해 가장 간단한 예를 들어 봅시다. 둘은 POM 파일 소개 종속성 및 속성 파일의 구성과 다릅니다. JSP를 사용하는 경우 Thymeleaf 의존성을 소개하지 마십시오. 물론, Thymeleaf를 사용할 때는 JSP 의존성을 소개하지 마십시오. 충돌을 일으킬 수 있습니다. Spring Boot 공무원은 Thymeleaf 사용을 권장합니다. 나는 개인적으로 그것이 좋다고 생각합니다. 프로젝트를 시작합시다!
1. 먼저 Meven 프로젝트를 구축하고 건축 된 프로젝트의 전체 구조를 확인하십시오.
프로젝트 구조를 구축하고 pom.xml을 사용하십시오. 이 데모는 Thymeleaf 만 사용합니다. 데이터베이스 종속성은 없으며 종속성이 거의 필요하지 않습니다.
<project xmlns = "http://maven.apache.org/pom/4.0.0"xmlns : xsi = "http://www.w3.org/2001/xmlschema-instance"xsi : schemalocation = "http://maven.apache.org/pom/0.0.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd "> <modelversion> 4.0.0 </modelversion> <groupid> springboot_bootstrap </groupid> <artifactid> springboot_bootstrap </artifactid> <version> 0.0.1-snapshot> <spershot> <-snapshot> <groupid> org.springframework.boot </groupid> <artifactid> 스프링-부트 스타터-팔렌트 </artifactid> <bersion> 1.4.7. release </version> <realativePath/> <!-저장소에서의 조회 부모-> </parent> <속성> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <project.reporting.outputencoding> utf-8 </project.reporting.outputencoding> <java.version> 1.8 </java.version> </properties> <pelovemencies> <groupid> org.springframework.boot </groupid> <artifactid> spring-boot-starter </artifactid> </fectionency> <pectionency> <groupid> org.springframework.boot </groupid> <artifactid> spring-boot-starter-web </arevifact> <GroupId> org.springframework.boot </groupid> <artifactid> Spring-boot-starter-Thymeleaf </arevifactid> </dependency> </dependencies> <flugins> <groupId> org.springFramework.boot </groupId> spring-bboot-maven-plugin </artifactid> </플러그인> </빌드> </project>
src /main /resource에서 application.properties 파일을 작성하십시오
Server.port = 8080 Server.Session.Timeout = 10 Server.tomcat.uri-Encoding = UTF-8 Spring.thymeleaf.prefix = classpath :/ views/ spring.thymeleaf.suffix = .html spring.thymeleaf.mode = html5 spring.thymeleaf.encoding = utf-8 spring.thymeleaf.content-type = text/html spring.thymeleaf.cache = false
포트 프로그램을 작성하십시오
패키지 com.zanghan.youyu; org.springframework.boot.springApplication import; org.springframework.boot.autoconfigure.springbootapplication import; @SpringBootApplication public class youyuapplication {public static void main (String [] args) {springApplication.run (youyuapplication.class, args); }} 컨트롤러 점프 부트 스트랩 인터페이스
패키지 com.zanghan.youyu.controller; org.springframework.stereotyp.controller import; org.springframework.web.bind.annotation.requestmapping; @controller public class logincontroller {@requestmapping ( "/") public String index () {return "/index"; }}부트 스트랩 JS CSS를 어디에서 소개할까요? 정적 폴더에 넣으면 페이지가보기에 배치됩니다.
index.html 인터페이스는 src/main/resource의 뷰 폴더에 저장됩니다. 왜 Tepmates가 아닌가? 속성 구성 파일의 컨텐츠는보기로 작성되므로 Thymeleaf의 접두사와 접미사를 변경할 수 있습니다.
<! doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"xmlns : th = "http://www.thymeleaf.org" xmlns : sec = "http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"> <head> <meta charset = "utf-8"/> <meta http-equiv = "x-ua-compatible"content = "IE = ater" 초기 스케일 = 1 "/> <title> mes 플랫폼 </title> <!-bootstrap-> <링크 Th : href ="@{bootstrap/bootstrap/css/bootstrap.min.css} "rel ="Stylesheet "/> <!-font savice-> 링크 th : href = "@{bootstrap/font-awesome/css/font-awesome.min.css}"rel = "Stylesheet"/> <!-[IF IE 7]> <int th : href = "@{bootstrap/sidebar-menu/sidebar-menu.css}"rel = "stylesheet"/> <link th : href = "@{bootstrap/ace/css/ace-rtl.min.css}"rel = "Stylesheet"/> <링크 th : href = "@{bootstrap/ace/css/ace-skins.min.css}"rel = "Stylesheet"/> <script th : src = "@{bootstrap/jquery-1.9.1.min.js}"> </script> script Th : src = "@{bootstrap/bootstrap/js/bootstrap.min.js}"> </script> <script th : src = "@{bootstrap/sidebar-menu/sidebar-menu.js}"> </script> <script Th : src = "@{bootstrap/bootstrap/js/bootstrap-tab.js}"> </script> <!-[lt IE 9]> <script src = "/scripts/html5shiv.js"> </script> </script> </script> src = "/scripts/respond.min.js"> </script> <스타일 유형 = "text/css"> body {font-size : 12px; } .nav> li> a {패딩 : 5px 10px; } .TAB-Content {Padding-Top : 3px; . </ul> <div role = "navigation"> <ul> <li style = "높이 : 50px;"> <data-toggle = "dropdown"href = "#"> <img src = "content/ace/avatars/avatar2.png"/> <span> <small> welcome, </small> 1310177 </span> </i> </i>>>>>>>>>>>>>> <li> </i> <li> href = "#"> <i> </i> 설정 </a> </a> </li> <li> <a href = "#"> <i> </i> 프로파일 </a> </li> <li> </li> <li> <a href = "/home/logout"> <i> </i> elevit </a </li> </li> </li> </li> </li> </li> </li> </li> </li> </li> </li> </li> </div> </div> <div id = "main-container"> <div> <div> <div id = "sidebar"> <div id = "sidebar"> <div id = "sidebar-collapse"style = "display : none;"> <i data-icon1 = "icon-double-angagle-left"data-icon2 = "</i </</</</</</<i data-icon1 ="> <i data-icon1 = "> <i data-icon1 ="> </</<ul> </</<i data-icon1. id = "menu"> </ul> </div> <div> <div> <div> <div> <div> <div> <div style = "padding-left : 5px;"> <ul 역할 = "TACKIST"> <li> <a href = "#index"역할 = "탭"DATOGGLE = "TAB"> 시스템 홈페이지 </ul> <divy style = "ably height = 1000px"> 역할 = "tabpanel"id = "index"style = "Height : 100%"> <h2> 백엔드 관리 시스템에 오신 것을 환영합니다 </h2> </div> </div> </div> </div> </div> </div> <script type = "text/javascript"> //toachtions.poscr.options = 'TORAST-Bottom-Right'; $ (function () {$ ( '#menu'). sidebarmenu ({data : [{id : '1', 텍스트 : '시스템 설정', 아이콘 : 'Icon-cog', url : '', menus : [{id : '2', text : '코딩 관리 1', 아이콘 : 'Icon-Glass', url : '', 'e,', ',', ',', ',', ',' ',' ' 아이콘 : '아이콘-글라스', '', 메뉴 : [{id : '2', 텍스트 : '코딩 관리 1', 아이콘 : '아이콘 글래스', url : '',}, {id : '3', '코딩 관리 2', 아이콘 : '아이콘 글래스', url : '',}, {텍스트 : ','텍스트 : ','코딩 관리 2 ','코딩 관리 2 '. 'icon-glass', url : '',}]}}]}]}]}); $ (children). $ ( "#sidebar"). attr ( "class", "sidebar display"); </script> <script th : src = "@{bootstrap/ace/js/ace-extra.min.js}"> </script> <script th : src = "@{bootstrap/ace/ace.min.js}"> </script> </html>완료하고 응용 프로그램을 실행하고 LocalHost : 8080을 입력하십시오
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.