国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

簡單! springboot 項目,訪問返回 Hello SpringBoot !

2019-11-10 19:27:33
字體:
來源:轉載
供稿:網(wǎng)友

sPRingboot 項目,訪問返回 Hello SpringBoot !

準備

瀏覽器jdk8uploading...

idea(自備 ide 技能均可)

新建項目

進入 Spring 官網(wǎng)點擊 【Start a new Spring Project】直達

推薦選擇 grandle, 配置文件清爽不少

選擇如下

簡單介紹

各個組件Web: 集成 SpringMVCSecurity:JPA:Actuator:Thymeleaf:MySQL:Lombok:HSQLDB:

SpringBoot 1.4.2 文檔

Idea 導入

解壓后到目錄下改 build.gradle 中 elipse 為 idea,這是因為我用的 idea, eclipse 的話應該不用改,不過我沒試過。然后直接在目錄下執(zhí)行

╰─$ ./gradlew idea

完成后便可以直接用 idea 打開了

記得要 使用 import

點擊 Finish 完成,等ok。。。

啟動

運行 Daxueapplication.java

2017-01-05 09:01:27.132  WARN 53547 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)2017-01-05 09:01:27.138 ERROR 53547 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATION FAILED TO START***************************Description:Cannot determine embedded database driver class for database type NONEAction:If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

啟動失敗,問題是缺少數(shù)據(jù)庫配置

解決:在 application.properties 里加數(shù)據(jù)庫配置,自己在 MySQL 里新建一個數(shù)據(jù)庫。application.properties 中內容如下:

spring.datasource.url=jdbc:mysql://localhost:3306/daxuespring.datasource.username=rootspring.datasource.passWord=123qwe# update 模式會自動建表,有改動后也會更新,不過不會刪原來的東西spring.jpa.properties.hibernate.hbm2ddl.auto=updatespring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialectspring.jpa.properties.hibernate.connection.release_mode=auto

OK,啟動完畢看結果

此時目錄結構如下

╰─$ tree -a.├── .gitignore├── .gradle│   └── 2.13│       └── taskArtifacts│           ├── cache.properties│           ├── cache.properties.lock│           ├── fileHashes.bin│           ├── fileSnapshots.bin│           └── taskArtifacts.bin├── build.gradle├── daxue.iml├── daxue.ipr├── daxue.iws├── gradle│   └── wrapper│       ├── gradle-wrapper.jar│       └── gradle-wrapper.properties├── gradlew├── gradlew.bat└── src    ├── main    │   ├── java    │   │   └── cn    │   │       └── dxs2s    │   │           ├── DaxueApplication.java    │   │           ├── domain    │   │           ├── service    │   │           └── web    │   │               └── IndexController.java    │   └── resources    │       ├── application.properties    │       ├── static    │       └── templates    └── test        └── java            └── cn                └── dxs2s                    └── DaxueApplicationTests.java

沒有 MySQL ? 木有關系,這么辦

更改一下依賴再刷新即可hslqdb 是一個內存數(shù)據(jù)庫,一般用來測試用,在使用 JPA 的方式下可以無縫切換到 MySQL。沒有 MySQL 的環(huán)境可以暫時頂用一下。

再次啟動

訪問 http://localhost:8080SpringSecurity 的默認基本安全配置,密碼請在啟動的日志中自行尋找。

目標達成!


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 宝山区| 南开区| 竹北市| 休宁县| 桓台县| 淮北市| 资溪县| 肥西县| 华宁县| 崇州市| 陇西县| 靖宇县| 寿宁县| 泌阳县| 广灵县| 罗甸县| 忻州市| 延边| 睢宁县| 盘锦市| 榆林市| 苍梧县| 稷山县| 池州市| 兴义市| 普陀区| 枣庄市| 都江堰市| 通城县| 顺平县| 晋州市| 新巴尔虎左旗| 冷水江市| 临邑县| 萝北县| 安义县| 拉孜县| 定南县| 刚察县| 宜州市| 洪洞县|