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

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Spring Boot 菜鳥教程 異常 集錦

2019-11-10 20:04:36
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

異常1.集成SPRing Data JPA

異常信息摘要:

org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. 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).

異常信息說(shuō)明:不知道使用什么數(shù)據(jù)庫(kù),需要在pom.xml標(biāo)注使用什么數(shù)據(jù)庫(kù),如h2 解決思路:修改pom.xml

<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope></dependency>

異常2.集成MyBatis沒有標(biāo)注@Mapper注解

異常信息摘要:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.jege.spring.boot.mybatis.UserMapperTest': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [com.jege.spring.boot.mybatis.mapper.UserMapper]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

異常信息說(shuō)明:說(shuō)mapper接口不能成功注入 解決思路:使用spring boot后沒有去指定掃描那個(gè)包,所以必須標(biāo)注@org.apache.ibatis.annotations.Mapper在接口類上面或者啟動(dòng)類標(biāo)注@MapperScan(“com.jege.spring.boot.mybatis.mapper”)


異常3.啟動(dòng)類必須放入包里面

異常信息摘要:

** WARNING ** : Your applicationContext is unlikely to start due to a @ComponentScan of the default package.

異常信息說(shuō)明:應(yīng)用程序不能從根目錄的包開始 Application.java 文件不能直接放在main/java文件夾下,必須要建一個(gè)包把他放進(jìn)去


異常4.上傳文件太大了

異常信息摘要:

org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field upfile exceeds its maximum permitted size of 1048576 bytes.

異常信息說(shuō)明:默認(rèn)最大上傳大小為1M 解決思路:Spring Boot升級(jí)到1.4到這樣配置

# MULTipART (MultipartProperties)spring.http.multipart.enabled=true # Enable support of multi-part uploads.spring.http.multipart.file-size-threshold=0 # Threshold after which files will be written to disk. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or Kilobyte size.spring.http.multipart.location= # Intermediate location of uploaded files.spring.http.multipart.max-file-size=10Mb # Max file size. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or Kilobyte size.spring.http.multipart.max-request-size=10Mb # Max request size. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or Kilobyte size.

解決思路:Spring Boot版本1.3.x這樣配置

multipart.maxFileSize=10Mb

異常5.tomcat版本問(wèn)題

異常信息摘要:

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()

異常信息說(shuō)明:找不到對(duì)應(yīng)的方法 在本地mvn springboot:run 運(yùn)行都沒有問(wèn)題。由于本地JDK版本是1.8,默認(rèn)版本是tomcat8;而服務(wù)器JDK版本是1.7。解決方法 指定 tomcat版本就可以了。

<properties> <tomcat.version>7.0.52</tomcat.version></properties>

如果覺得我的文章或者代碼對(duì)您有幫助,可以請(qǐng)我喝杯咖啡。 您的支持將鼓勵(lì)我繼續(xù)創(chuàng)作!謝謝! 微信打賞 支付寶打賞


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 印江| 合川市| 洛阳市| 澄江县| 万安县| 瑞金市| 诸城市| 平江县| 南部县| 筠连县| 疏附县| 德江县| 正蓝旗| 滨州市| 石嘴山市| 太保市| 白山市| 博白县| 长宁区| 耒阳市| 方城县| 通城县| 长丰县| 宁国市| 宝坻区| 光山县| 鹤庆县| 长岭县| 安义县| 和政县| 胶州市| 巴东县| 炉霍县| 新兴县| 都安| 阳高县| 万盛区| 濉溪县| 高州市| 宜宾市| 班戈县|