謹以此貼記錄springboot+mybatis-plus開發項目遇到的問題及解決方案
1、Web server failed to start. Port 8002 was already in use.
Identify and stop the process that's listening on port 8002 or configure this application to listen on another port.
問題原因:啟動類服務端口沖突(端口已被占用)
解決方案:修改此啟動類端口為未被占用的端口
2、Nginx配置請求轉發報500。
postman請求接口提示:500 Internal Server Error
前端訪問接口提示: No 'Access-Control-Allow-Origin' header is present on the requested resource.
問題原因:①、因controller加了 @CrossOrigin ,先排除跨域問題。
②、打開Nginx error_log開關(Nginx.config配置文件里),查看Nginx報錯日志。發現Nginx報錯原因:failed (13: Permission denied),權限問題。
解決方案:管理員權限啟動Nginx。
3、springboot啟動,控制台打印:Property 'mapperLocations' was not specified or no matching resources found
此時調用mapper.xml里的sql語句時,提示:Invalid bound statement (not found)
問題原因:springboot啟動時,src/main/java下只會掃描加載.java文件,而我的mapper.xml是放在src/main/java目錄下的。需要指定mapper.xml位置。
解決方案:網上查詢得知有2種方案
①、pom.xml添加加載的mepper.xml位置
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
②、application.properties添加 mapper-locations
mybatis-plus.mapper-locations=classpath:**/mapper/xml/*.xml
用后者居多。但是,我本地需要2種方法一起用,才可以正常加載mapper.xml文件。
4、Nuxt啟動報錯:vue-awesome-swiper/dist/ssr,swiper/dist/css/swiper.css未找到
問題及原因:①、缺少swiper模塊
vue-awesome-swiper模塊安裝后,提示:npm WARN vue-awesome-swiper@4.1.1 requires a peer of swiper@^5.2.0 but none is installed. You must install peer dependencies yourself.
②、nuxt.config.js、nuxt-swiper-plugin.js文件導入vue-awesome-swiper錯誤
解決方案:①、npm install swiper@提示的版本 安裝swiper
②、修改nuxt.config.js如下:
③、修改nuxt-swiper-plugin.js如下: