maven 错误的解决方法
首先,Intellij IDEA中是有内置maven 的,可以直接使用。
但是如果是使用系统内置的maven的话,第一次使用maven创建的项目会出现整版的错误,例如下面的,点击各种下载和刷新,都没有任何反应。
只会提示出现:Cannot resolve plugin org.springframework.boot:spring-boot-maven-plugin:2.2.6.RELEASE 等错误信息,
这种明显是maven的库的错误,不是项目需要的jar丢失,而是mavne的库丢失
这个时候我们需要点击
选中下面的全部点击安装,那你的Plugins 就能显示正常了
那么 Dependencies 中的错误该如何点击呢?
例如:
如果出现jar库警告,但是本地maven库之中又存在该资源文档。而且删除了重新下载还是出现红色警告。
那么主要原因在于该版本maven之中相关资源库其实还没有同步,建议降低你的spring-boot-starter 的版本;
降低该版本号,具体有多少版本,可以通过https://mvnrepository.com/ 网址进行查询, 输入spring boot starter 进行搜索
其实这个红色错误,一般不会影响到你的项目的运行。
修改完成之后:
就是正常状态下了。没有警告和错误
启动时报错Failed to determine a suitable driver class 解决方法
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.13.RELEASE)
2020-04-08 18:17:45.752 INFO 30384 --- [ main] c.i.s.whiteboard.WhiteboardApplication : Starting WhiteboardApplication on DZ-196 with PID 30384 (D:\SVNProject\WebServer\whiteboard\target\classes started by xxxx in D:\SVNProject\WebServer\whiteboard)
2020-04-08 18:17:45.758 INFO 30384 --- [ main] c.i.s.whiteboard.WhiteboardApplication : No active profile set, falling back to default profiles: default
2020-04-08 18:17:47.767 WARN 30384 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.irtouch.server.whiteboard]' package. Please check your configuration.
2020-04-08 18:17:48.816 INFO 30384 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-04-08 18:17:48.863 INFO 30384 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-04-08 18:17:48.864 INFO 30384 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.31]
2020-04-08 18:17:49.227 INFO 30384 --- [ main] o.a.c.c.C.[.[localhost].[/whiteboard] : Initializing Spring embedded WebApplicationContext
2020-04-08 18:17:49.228 INFO 30384 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3383 ms
2020-04-08 18:17:49.686 INFO 30384 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-08 18:17:49.814 INFO 30384 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2020-04-08 18:17:49.955 WARN 30384 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2020-04-08 18:17:49.956 INFO 30384 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-04-08 18:17:49.963 INFO 30384 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-04-08 18:17:49.985 INFO 30384 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-04-08 18:17:50.000 ERROR 30384 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
[0x7FF9CD166230] ANOMALY: meaningless REX prefix used
Process finished with exit code 1
其实主要原因在于数据库配置,无法实例化,造成springboot 无法启动
因为创建项目的时候,引用了JDBC库,才会出现的问题。需要主动将jdbc相关配置信息添加进去,才能成功
解决方法:
application中先配置DataSource基本信息
首先确认 resources 目录下的application文件的后缀,直接rename 修改后缀为 yml
然后在 application.yml 文件之中填写下面的代码。
spring:
datasource:
url: jdbc:mysql://localhost:3306/test
name: test
username: wevServer
password: webServer2020
driver-class-name: com.mysql.cj.jdbc.Driver
关键是driver-class-name 配置了jdbc加载的驱动。
运行时就能够正常访问了
如果你数据库都还不存在,未添加,那么建议pom之中,将jdbc相关的库全部注释即可
请注意,如果出现下面的警告错误
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `
com.mysql.cj.jdbc.Driver'.
The driver is automatically
registered via the SPI and manual
loading of the driver class is generally unnecessary.
如果是这个错误那么主要是因为 driver-class-name 类写的是老版本了。com.mysql.jdbc.Driver 已经被废弃了。
调整为com.mysql.cj.jdbc.Driver 就可以了。
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezon 错误
IDEA 添加Database 提示Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezon
我们如果通过Intellij idea 之中的Database 管理MySQL数据库时,
然后提示Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezon
错误时,该如何处理?
端口正常,Host 正确,User 正确,password 正确。这种情况下,提示时区。
这主要是驱动挂载的问题。 而不用到mysql之中设置时区。
在这里,将Driver 驱动设置为MySQL for 5.1 就可以了
如果没有该驱动,会自动进行下载加载
确保正确就可以了。
评论区