Reputation: 123
I'm new into SpringMVC and got stuck here.
I created a Spring Boot application through Spring Initializr and then
created HomeController
, connected it with index.jsp
. It was working
fine but when I added SearchController
, connected with search.jsp
, it
dosen't work now. Before adding SearcController
, the application was
running fine but then it says:
Failed to execute goal ...plugin:2.4.0:run (default-cli) on project hplus : Application finished with exit code: 1
Update: after doing some searches I found out that my database's server was not running and after running that, and running my application as Test, I got this error.
Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set .
Full Error!
Test set:HplusappApplicationTests
<<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
.
pom.xml file ->
<code>
xml
<?xml version="1.0" encoding="UTF-8"?>
<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/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>spring-example</groupId>
<artifactId>myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>myapp</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties ->
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/hplus
spring.datasource.username=root
spring.datasource.password=root
Upvotes: 3
Views: 4109
Reputation: 123
Solution After searching for more than two days, I found out it's the timeZone problem.
I edited application.properties, line two ->
spring.datasource.url=jdbc:mysql://localhost:3306/hplus?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
https://stackoverflow.com/a/56537473/14623694
It solved the issue.
Upvotes: 1
Reputation: 31
There seems to be error's when defining the bean and also your pom file, have you tried running a clean instal, with the
mvn clean instal
command? If that still doesn't work try to look at your pom and application.properties file is there still some mixed versions? If that still doesn't work try deleting your .m2 file and run the mvn clean install once again.
Upvotes: 0
Reputation: 36
You need to specify the MySQL dialect Hibernate should use :
put this in application.properties:
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
Upvotes: 0
Reputation: 532
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
It clearly says that you entered a wrong mvn
command. What is the command you executed?
We generally run mvn clean install
to build an application.
Here is a list of Maven commands that might help you.
Upvotes: 0