Springboot maven project issue (moving src/main/java and pom.xml to "backend" folder
I have created a spring boot(maven project) in IntelliJ with some dependencies such as Spring Web, Spring JPA Data, Postgresl Driver and etc.
By the start, i have edited application.settings to connect to my database which is postgresl and it works fine. But I wanted to create a folder called “backend” and moved src/main/java and pom.xml into it. This is where come to the error:
2023-10-10T19:14:43.813+08:00 INFO 24280 --- [ restartedMain] c.e.s.SimpleLogin2Application : Starting SimpleLogin2Application using Java 17.0.1 with PID 24280 (C:\Users\mike\IdeaProjects\simpleLogin2\backend\target\classes started by mike in C:\Users\mike\IdeaProjects\simpleLogin2)
2023-10-10T19:14:43.817+08:00 INFO 24280 --- [ restartedMain] c.e.s.SimpleLogin2Application : No active profile set, falling back to 1 default profile: "default"
2023-10-10T19:14:43.877+08:00 INFO 24280 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-10-10T19:14:43.877+08:00 INFO 24280 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-10-10T19:14:44.586+08:00 INFO 24280 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-10-10T19:14:44.602+08:00 INFO 24280 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 10 ms. Found 0 JPA repository interfaces.
2023-10-10T19:14:45.216+08:00 INFO 24280 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-10-10T19:14:45.223+08:00 INFO 24280 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-10-10T19:14:45.223+08:00 INFO 24280 --- [ restartedMain] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.13]
2023-10-10T19:14:45.282+08:00 INFO 24280 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-10-10T19:14:45.282+08:00 INFO 24280 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1404 ms
2023-10-10T19:14:45.347+08:00 WARN 24280 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
2023-10-10T19:14:45.350+08:00 INFO 24280 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2023-10-10T19:14:45.369+08:00 INFO 24280 --- [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-10-10T19:14:45.388+08:00 ERROR 24280 --- [ restartedMain] 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).
Process finished with exit code 0
i have tried couple of way like edit source repository under pom.xml but it doesnt work. Hopefully hope to get the solution.
请先登录再写评论。
Hello!
When using Maven it is strongly recommended to adhere to the Standard Directory Layout.
However, if you have to implement a custom directory layout for your Project, I would suggest the following article from the Maven Documentation.
Let me know if it helps with the issue!