In Spring Starter Project, Values are not fetching into h2 database [duplicate] - spring-boot

This question already has answers here:
Spring Boot is not creating tables automatically
(3 answers)
Closed 1 year ago.
I'm new to Spring Framework. While Creating Spring Starter Project, I've selected Web,JPA & H2 database then I've created Alien.Class with 2 Variables and i've created data.sql file, by using this file i've tried to fetch the values into h2 database. But after adding data.sql file, i got an error that shows Failed to execute SQL script statement nested exception is Table "ALIEN" not found; SQL statement: insert into alien values (101, 'Vikram').Please, give a solution for this.
1.Alien.Class
package com.telusko.demo.model;
import javax.persistence.Entity;
import javax.persistence.Id;
#Entity
public class Alien
{
#Id
private int aid;
private String aname;
public int getAid() {
return aid;
}
public void setAid(int aid) {
this.aid = aid;
}
public String getAname() {
return aname;
}
public void setAname(String aname) {
this.aname = aname;
}
#Override
public String toString() {
return "Alien [aid=" + aid + ", aname=" + aname + "]";
}
}
2.home.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="addAlien">
<input type="text" name="aid"><br>
<input type="text" name="aname"><br>
<input type="submit">
</form>
</body>
</html>
3.AlienController
ackage com.telusko.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class AlienController
{
#RequestMapping("/")
public String home()
{
return "home.jsp";
}
}
4.application.properties
server.port=8082
spring.profiles.active=#spring.profiles.active#
spring.h2.console.enabled=true
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:navin
spring.jpa.open-in-view=false
5.data.sql
insert into alien values (101,'Navin');
6.Console error
[2m2021-05-31 07:17:51.919[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.telusko.demo.BootjpaApplication [0;39m [2m:[0;39m Starting BootjpaApplication using Java 15.0.2 on DESKTOP-JF5BSMC with PID 2788 (C:\Users\Lakshmana Sai\SpringWorkspace\bootjpa\target\classes started by Lakshmana Sai in C:\Users\Lakshmana Sai\SpringWorkspace\bootjpa)
[2m2021-05-31 07:17:51.923[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.telusko.demo.BootjpaApplication [0;39m [2m:[0;39m The following profiles are active: #spring.profiles.active#
[2m2021-05-31 07:17:52.856[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data JPA repositories in DEFAULT mode.
[2m2021-05-31 07:17:52.876[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 8 ms. Found 0 JPA repository interfaces.
[2m2021-05-31 07:17:53.672[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8082 (http)
[2m2021-05-31 07:17:53.690[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2021-05-31 07:17:53.691[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/9.0.46]
[2m2021-05-31 07:17:54.111[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.apache.jasper.servlet.TldScanner [0;39m [2m:[0;39m At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2m2021-05-31 07:17:54.124[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2021-05-31 07:17:54.124[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 2125 ms
[2m2021-05-31 07:17:54.166[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2021-05-31 07:17:54.462[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2021-05-31 07:17:54.476[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.a.h2.H2ConsoleAutoConfiguration [0;39m [2m:[0;39m H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:navin'
[2m2021-05-31 07:17:54.680[0;39m [33m WARN[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scriptDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration$SharedCredentialsDataSourceInitializationConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Lakshmana%20Sai/SpringWorkspace/bootjpa/target/classes/data.sql]: insert into alien values (101,'Navin'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ALIEN" not found; SQL statement:
insert into alien values (101,'Navin') [42102-200]
[2m2021-05-31 07:17:54.682[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Shutdown initiated...
[2m2021-05-31 07:17:54.693[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Shutdown completed.
[2m2021-05-31 07:17:54.705[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Stopping service [Tomcat]
[2m2021-05-31 07:17:54.745[0;39m [32m INFO[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2021-05-31 07:17:54.844[0;39m [31mERROR[0;39m [35m2788[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scriptDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration$SharedCredentialsDataSourceInitializationConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Lakshmana%20Sai/SpringWorkspace/bootjpa/target/classes/data.sql]: insert into alien values (101,'Navin'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ALIEN" not found; SQL statement:
insert into alien values (101,'Navin') [42102-200]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.7.jar:5.3.7]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.7.jar:5.3.7]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.7.jar:5.3.7]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:337) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325) ~[spring-boot-2.5.0.jar:2.5.0]
at com.telusko.demo.BootjpaApplication.main(BootjpaApplication.java:10) ~[classes/:na]
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Lakshmana%20Sai/SpringWorkspace/bootjpa/target/classes/data.sql]: insert into alien values (101,'Navin'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ALIEN" not found; SQL statement:
insert into alien values (101,'Navin') [42102-200]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:622) ~[spring-jdbc-5.3.7.jar:5.3.7]
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254) ~[spring-jdbc-5.3.7.jar:5.3.7]
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49) ~[spring-jdbc-5.3.7.jar:5.3.7]
at org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer.runScripts(DataSourceScriptDatabaseInitializer.java:72) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializationConfiguration$InitializationModeDataSourceScriptDatabaseInitializer.runScripts(DataSourceInitializationConfiguration.java:204) ~[spring-boot-autoconfigure-2.5.0.jar:2.5.0]
at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.runScripts(AbstractScriptDatabaseInitializer.java:131) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.applyScripts(AbstractScriptDatabaseInitializer.java:91) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.applyDataScripts(AbstractScriptDatabaseInitializer.java:85) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.initializeDatabase(AbstractScriptDatabaseInitializer.java:76) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.afterPropertiesSet(AbstractScriptDatabaseInitializer.java:65) ~[spring-boot-2.5.0.jar:2.5.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845) ~[spring-beans-5.3.7.jar:5.3.7]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) ~[spring-beans-5.3.7.jar:5.3.7]
... 18 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ALIEN" not found; SQL statement:
insert into alien values (101,'Navin') [42102-200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) ~[h2-1.4.200.jar:1.4.200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200]
at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.200.jar:1.4.200]
at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Parser.readTableOrView(Parser.java:7628) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Parser.readTableOrView(Parser.java:7599) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Parser.parseInsert(Parser.java:1747) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Parser.parsePrepared(Parser.java:954) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Parser.parse(Parser.java:843) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Parser.parse(Parser.java:815) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Parser.prepareCommand(Parser.java:738) ~[h2-1.4.200.jar:1.4.200]
at org.h2.engine.Session.prepareLocal(Session.java:657) ~[h2-1.4.200.jar:1.4.200]
at org.h2.engine.Session.prepareCommand(Session.java:595) ~[h2-1.4.200.jar:1.4.200]
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235) ~[h2-1.4.200.jar:1.4.200]
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:212) ~[h2-1.4.200.jar:1.4.200]
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201) ~[h2-1.4.200.jar:1.4.200]
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-4.0.3.jar:na]
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-4.0.3.jar:na]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:601) ~[spring-jdbc-5.3.7.jar:5.3.7]
... 29 common frames omitted

H2 is trying to make table names to uppercase and doing case sensitive search so it is unable to find the table.
Try to use ;DATABASE_TO_UPPER=FALSE property and see if it works.
spring.datasource.url=jdbc:h2:mem:navin;DATABASE_TO_UPPER=FALSE

Related

Eureka Server Exception starting filter [servletContainer] error and Eureka Server not starting

I have made a Eureka Server in Spring Tool Suite but when I am running it as a Spring Application I am getting this error:
[2m2022-12-05 13:15:10.439[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.c.c.ConfigServicePropertySourceLocator[0;39m [2m:[0;39m Fetching config from server at : http://localhost:8888
[2m2022-12-05 13:15:10.564[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.c.c.ConfigServicePropertySourceLocator[0;39m [2m:[0;39m Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
[2m2022-12-05 13:15:10.564[0;39m [33m WARN[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.c.c.ConfigServicePropertySourceLocator[0;39m [2m:[0;39m Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/Eureka-server/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
[2m2022-12-05 13:15:10.566[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.vipul.EurekaServerApplication [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2022-12-05 13:15:11.405[0;39m [33m WARN[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.actuate.endpoint.EndpointId [0;39m [2m:[0;39m Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
[2m2022-12-05 13:15:11.735[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.cloud.context.scope.GenericScope [0;39m [2m:[0;39m BeanFactory id=0c9a9003-56ac-33ba-b45b-bb86d98d68ff
[2m2022-12-05 13:15:11.828[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$5cbea4b1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2022-12-05 13:15:12.188[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 5055 (http)
[2m2022-12-05 13:15:12.217[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2022-12-05 13:15:12.217[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet Engine: Apache Tomcat/9.0.12
[2m2022-12-05 13:15:12.231[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.a.catalina.core.AprLifecycleListener [0;39m [2m:[0;39m The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Users\sbans\Downloads\sts-4.16.1.RELEASE\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20221004-1257\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Users/sbans/Downloads/sts-4.16.1.RELEASE//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20221004-1257/jre/bin/server;C:/Users/sbans/Downloads/sts-4.16.1.RELEASE//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20221004-1257/jre/bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;%sbans%\AppData\Roaming\Composer\vendor\bin;C:\Program Files\Java\jdk1.8.0_151\bin;C:\Program Files\Git\cmd;C:\Program Files\MATLAB\R2019b\bin;C:\Program Files\PuTTY\;C:\Program Files\nodejs\;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\sbans\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\sbans\AppData\Local\Programs\Python\Python37\;C:\Users\sbans\AppData\Local\Microsoft\WindowsApps;C:\Users\sbans\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sbans\AppData\Roaming\Composer\vendor\bin;C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.3\bin;;C:\Program Files\Oracle\VirtualBox;C:\Users\sbans\AppData\Roaming\npm;C:\Program Files\Java\jdk-17.0.5;;C:\Users\sbans\Downloads\sts-4.16.1.RELEASE;;.]
[2m2022-12-05 13:15:12.443[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2022-12-05 13:15:12.443[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.web.context.ContextLoader [0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 1857 ms
[2m2022-12-05 13:15:12.583[0;39m [33m WARN[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.c.sources.URLConfigurationSource [0;39m [2m:[0;39m No URLs will be polled as dynamic configuration sources.
[2m2022-12-05 13:15:12.584[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.n.c.sources.URLConfigurationSource [0;39m [2m:[0;39m To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2m2022-12-05 13:15:12.603[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.netflix.config.DynamicPropertyFactory [0;39m [2m:[0;39m DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration#2616b618
[2m2022-12-05 13:15:14.239[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.cloud.commons.util.InetUtils [0;39m [2m:[0;39m Cannot determine local hostname
[2m2022-12-05 13:15:15.448[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.cloud.commons.util.InetUtils [0;39m [2m:[0;39m Cannot determine local hostname
[2m2022-12-05 13:15:15.676[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean [0;39m [2m:[0;39m Mapping filter: 'characterEncodingFilter' to: [/*]
[2m2022-12-05 13:15:15.676[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean [0;39m [2m:[0;39m Mapping filter: 'webMvcMetricsFilter' to: [/*]
[2m2022-12-05 13:15:15.677[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean [0;39m [2m:[0;39m Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
[2m2022-12-05 13:15:15.677[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean [0;39m [2m:[0;39m Mapping filter: 'formContentFilter' to: [/*]
[2m2022-12-05 13:15:15.677[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean [0;39m [2m:[0;39m Mapping filter: 'requestContextFilter' to: [/*]
[2m2022-12-05 13:15:15.677[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean [0;39m [2m:[0;39m Mapping filter: 'httpTraceFilter' to: [/*]
[2m2022-12-05 13:15:15.677[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.FilterRegistrationBean [0;39m [2m:[0;39m Mapping filter: 'servletContainer' to urls: [/eureka/*]
[2m2022-12-05 13:15:15.677[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.servlet.ServletRegistrationBean [0;39m [2m:[0;39m Servlet dispatcherServlet mapped to [/]
[2m2022-12-05 13:15:15.794[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mc.s.j.s.i.a.WebApplicationImpl [0;39m [2m:[0;39m Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
[2m2022-12-05 13:15:15.871[0;39m [31mERROR[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Exception starting filter [servletContainer]
[2m2022-12-05 13:15:15.873[0;39m [31mERROR[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardContext [0;39m [2m:[0;39m One or more Filters failed to start. Full details will be found in the appropriate container log file
[2m2022-12-05 13:15:15.873[0;39m [31mERROR[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardContext [0;39m [2m:[0;39m Context [] startup failed due to previous errors
[2m2022-12-05 13:15:15.879[0;39m [33m WARN[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.a.c.loader.WebappClassLoaderBase [0;39m [2m:[0;39m The web application [ROOT] appears to have started a thread named [spring.cloud.inetutils] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base#17.0.4.1/java.net.Inet6AddressImpl.getHostByAddr(Native Method)
java.base#17.0.4.1/java.net.InetAddress$PlatformNameService.getHostByAddr(InetAddress.java:939)
java.base#17.0.4.1/java.net.InetAddress.getHostFromNameService(InetAddress.java:662)
java.base#17.0.4.1/java.net.InetAddress.getHostName(InetAddress.java:605)
java.base#17.0.4.1/java.net.InetAddress.getHostName(InetAddress.java:577)
app//org.springframework.cloud.commons.util.InetUtils$$Lambda$189/0x00000001002793e8.call(Unknown Source)
java.base#17.0.4.1/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base#17.0.4.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base#17.0.4.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base#17.0.4.1/java.lang.Thread.run(Thread.java:833)
[2m2022-12-05 13:15:15.882[0;39m [31mERROR[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.apache.catalina.core.ContainerBase [0;39m [2m:[0;39m A child container failed during start
[2m2022-12-05 13:15:15.884[0;39m [31mERROR[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.apache.catalina.core.ContainerBase [0;39m [2m:[0;39m A child container failed during start
[2m2022-12-05 13:15:15.884[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Stopping service [Tomcat]
[2m2022-12-05 13:15:15.885[0;39m [33m WARN[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
[2m2022-12-05 13:15:15.901[0;39m [32m INFO[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2022-12-05 13:15:15.904[0;39m [31mERROR[0;39m [35m12152[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at com.vipul.EurekaServerApplication.main(EurekaServerApplication.java:12) ~[classes/:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:125) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
... 8 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:960) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:370) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:106) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE]
... 13 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:951) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
... 21 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:960) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
... 21 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:951) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
... 29 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [WebappLoader[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:267) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5367) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:187) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
... 29 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field static final java.io.ClassCache java.io.ObjectStreamClass$Caches.localDescs accessible: module java.base does not "opens java.io" to unnamed module #5965d37
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) ~[na:na]
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172) ~[na:na]
at org.apache.catalina.loader.WebappClassLoaderBase.clearCache(WebappClassLoaderBase.java:2206) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesObjectStreamClassCaches(WebappClassLoaderBase.java:2194) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.loader.WebappClassLoaderBase.clearReferences(WebappClassLoaderBase.java:1567) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.loader.WebappClassLoaderBase.stop(WebappClassLoaderBase.java:1497) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:442) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) ~[tomcat-embed-core-9.0.12.jar:9.0.12]
... 38 common frames omitted
Here is my POM.XML for Eureka Server:
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vipul</groupId>
<artifactId>EurekaServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>EurekaServer</name>
<description>Project for Eureka Server</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Here is application.properties for Eureka Server:
spring.application.name=Eureka-server
server.port=5055
eureka.client.fetch-registry=false
eureka.client.register-with-eureka=false
eureka.client.service-url.defaultZone=http://localhost:5055/eureka
My configuration server is working but I am not able to start the Eureka server due to this.
Can anyone help to resolve this error as I am not able to fix this.

MVC project Role based authentication for admin and normal user using database for getting role details

The Role-based authentication system where there will be some admin and some normal users. I am trying to configure the system in such a way that depending on the role of the user they will be able to login using different URLs and after that, they can perform their intended task. The following code is used for the configuration
This is for userDetail
package com.multiauthentication.config;
import java.util.Collection;
import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.multiauthentication.entity.User;
public class CustomUserDetails implements UserDetails {
private User user;
public CustomUserDetails(User user) {
this.user = user;
}
#Override
public Collection<? extends GrantedAuthority> getAuthorities() {
SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(user.getUserRole());
return List.of(simpleGrantedAuthority);
}
#Override
public String getPassword() {
return user.getPassword();
}
#Override
public String getUsername() {
return user.getEmailAddress();
}
#Override
public boolean isAccountNonExpired() {
// TODO Auto-generated method stub
return true;
}
#Override
public boolean isAccountNonLocked() {
return true;
}
#Override
public boolean isCredentialsNonExpired() {
return true;
}
#Override
public boolean isEnabled() {
return true;
}
}
This is for userService detail
package com.multiauthentication.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import com.multiauthentication.config.CustomUserDetails;
import com.multiauthentication.dao.UserRepository;
import com.multiauthentication.entity.User;
public class UserDetailsServiceImpl implements UserDetailsService{
#Autowired
private UserRepository userRepository;
#Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// Fetch user from Database
User user = this.userRepository.getUserByUserEmail(username);
if(user == null) {
throw new UsernameNotFoundException("Could not found user");
}
CustomUserDetails userDetails = new CustomUserDetails(user);
return userDetails;
}
}
And this is for application configuration
package com.multiauthentication.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import com.multiauthentication.service.UserDetailsServiceImpl;
#Configuration
#EnableWebSecurity
public class WebConfig {
#Bean
public UserDetailsService getDetailsService() {
return new UserDetailsServiceImpl();
}
#Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
#Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
daoAuthenticationProvider.setUserDetailsService(this.getDetailsService());
daoAuthenticationProvider.setPasswordEncoder(this.passwordEncoder());
return daoAuthenticationProvider;
}
// Configure Method
#Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration)
throws Exception {
return authenticationConfiguration.getAuthenticationManager();
}
#Configuration
#Order(1)
public static class AppConfigurationAdapter1 {
// Configure HttpSecurity for Admin
#Bean
protected SecurityFilterChain filterChain1(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests()
.antMatchers("/admin/**").hasRole("ADMIN")
.and()
.formLogin()
.loginPage("/loginAdmin")
.loginProcessingUrl("/admin_login")
.defaultSuccessUrl("/admin/index")
.and()
.logout()
.logoutUrl("/admin_logout")
.logoutSuccessUrl("/protectedLinks")
.deleteCookies("JSESSIONID")
.and()
.exceptionHandling()
.accessDeniedPage("/403")
.and()
.csrf().disable();
return http.build();
}
}
#Configuration
#Order(2)
public static class AppConfigurationAdapter2 {
// Configure HttpSecurity for User
#Bean
protected SecurityFilterChain filterChain2(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests()
.antMatchers("/user/**").hasRole("NORMAL")
.and()
.formLogin()
.loginPage("/loginUser")
.loginProcessingUrl("/user_login")
.defaultSuccessUrl("/user/index")
.and()
.logout()
.logoutUrl("/user_logout")
.logoutSuccessUrl("/protectedLinks")
.deleteCookies("JSESSIONID")
.and()
.exceptionHandling()
.accessDeniedPage("/403")
.and()
.csrf().disable();
return http.build();
}
}
}
The entity class is defined and declared in the following way
package com.multiauthentication.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
#Entity
#Table(name = "users")
#Getter
#Setter
#NoArgsConstructor
#AllArgsConstructor
#ToString
public class User {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "id")
private int id;
#Column(name = "user_name")
private String userName;
#Column(name = "email_address")
private String emailAddress;
#Column(name = "password")
private String password;
#Column(name = "user_role")
private String userRole;
#Column(name = "user_enabled")
private boolean userEnabled;
}
The login for Admin is properly working and able to hit the defaultSuccessUrl("/admin/index") but for the normal it is not. Whenever the I tried to login using credentials of normal user it get stuck on loginProcessingUrl("/user_login") for your reference I am attaching both page for user login and response after that I get.
The Following logs is related to admin role which is successfull
2022-10-23 09:49:16.992[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-8][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/loginAdmin", parameters={}
[2m2022-10-23 09:49:16.993[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-8][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped to com.multiauthentication.controller.BasicController#customAdminLogin(Model)
[2m2022-10-23 09:49:16.996[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-8][0;39m [36mo.s.w.s.v.ContentNegotiatingViewResolver[0;39m [2m:[0;39m Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
[2m2022-10-23 09:49:17.039[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-8][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:49:17.050[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-9][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/CSS/style.css", parameters={}
[2m2022-10-23 09:49:17.050[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[io-8080-exec-10][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/JS/scriptfile.js", parameters={}
[2m2022-10-23 09:49:17.051[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-9][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:49:17.051[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[io-8080-exec-10][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:49:17.052[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[io-8080-exec-10][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:49:17.052[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-9][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
Hibernate: select user0_.id as id1_0_, user0_.email_address as email_ad2_0_, user0_.password as password3_0_, user0_.user_enabled as user_ena4_0_, user0_.user_name as user_nam5_0_, user0_.user_role as user_rol6_0_ from users user0_ where user0_.email_address=?
[2m2022-10-23 09:49:31.751[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/admin/index", parameters={}
[2m2022-10-23 09:49:31.751[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped to com.multiauthentication.controller.AdminController#showHomeAdmin(Model, Principal)
Hibernate: select user0_.id as id1_0_, user0_.email_address as email_ad2_0_, user0_.password as password3_0_, user0_.user_enabled as user_ena4_0_, user0_.user_name as user_nam5_0_, user0_.user_role as user_rol6_0_ from users user0_ where user0_.email_address=?
[2m2022-10-23 09:49:31.758[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.w.s.v.ContentNegotiatingViewResolver[0;39m [2m:[0;39m Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
[2m2022-10-23 09:49:31.782[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:49:31.791[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-3][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/CSS/style.css", parameters={}
[2m2022-10-23 09:49:31.792[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-3][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:49:31.794[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-4][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/JS/scriptfile.js", parameters={}
[2m2022-10-23 09:49:31.794[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-3][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:49:31.795[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-4][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:49:31.797[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-4][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:49:32.158[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-5][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/Image/Urban%20development%20Banner.png", parameters={}
[2m2022-10-23 09:49:32.158[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-5][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:49:32.162[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-5][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
And now this log is related to normal role which is not working properly
[2m2022-10-23 09:55:37.407[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-9][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/loginUser", parameters={}
[2m2022-10-23 09:55:37.408[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-9][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped to com.multiauthentication.controller.BasicController#customUserLogin(Model)
[2m2022-10-23 09:55:37.411[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-9][0;39m [36mo.s.w.s.v.ContentNegotiatingViewResolver[0;39m [2m:[0;39m Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8]
[2m2022-10-23 09:55:37.455[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-9][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:55:37.462[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[io-8080-exec-10][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/CSS/style.css", parameters={}
[2m2022-10-23 09:55:37.462[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/JS/scriptfile.js", parameters={}
[2m2022-10-23 09:55:37.463[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:55:37.463[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[io-8080-exec-10][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:55:37.465[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:55:37.465[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[io-8080-exec-10][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
[2m2022-10-23 09:55:56.532[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m POST "/user_login", parameters={masked}
[2m2022-10-23 09:55:56.533[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
[2m2022-10-23 09:55:56.540[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.w.s.r.ResourceHttpRequestHandler [0;39m [2m:[0;39m Resource not found
[2m2022-10-23 09:55:56.541[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 404 NOT_FOUND
[2m2022-10-23 09:55:56.542[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m "ERROR" dispatch for POST "/error", parameters={masked}
[2m2022-10-23 09:55:56.542[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
[2m2022-10-23 09:55:56.562[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.w.s.v.ContentNegotiatingViewResolver[0;39m [2m:[0;39m Selected 'text/html' given [text/html, text/html;q=0.8]
[2m2022-10-23 09:55:56.562[0;39m [32mDEBUG[0;39m [35m13680[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Exiting from "ERROR" dispatch, status 404

Spring boot 4 controller error: The method save(S) in the type CrudRepository<Fournisseur,Long> is not applicable for the arguments (Fournisseur)

I'am new with spring boot. I'am using Spring boot (4) data JPA and MySQL. The method findall worked fine for me for the class fournisseur but the save method wont work.
Here my class:
package net.javaguides.springboot.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name ="fournisseur")
public class Fournisseur {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long ID;
#Column(name="Name")
private String Name;
#Column(name="Address")
private String Address;
#Column(name="Phone")
private long Phone;
public Fournisseur() {
}
public Fournisseur(String name, String address, long phone) {
super();
Name = name;
Address = address;
Phone = phone;
}
public long getID() {
return ID;
}
public void setID(long iD) {
this.ID = iD;
}
public String getName() {
return Name;
}
public void setName(String name) {
this.Name = name;
}
public String getAddress() {
return Address;
}
public void setAddress(String address) {
this.Address = address;
}
public long getPhone() {
return Phone;
}
public void setPhone(long phone) {
this.Phone = phone;
}
}
Here my Repository:
package net.javaguides.springboot.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import net.javaguides.springboot.model.Fournisseur;
#Repository
public interface FournisseurRepository extends JpaRepository<Fournisseur,Long> {
}
Here my controller:
package net.javaguides.springboot.controller;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.javaguides.springboot.repository.FournisseurRepository;
#CrossOrigin(origins ="http://localhost:4200",maxAge=3600)
#RestController
#RequestMapping("/api/v1/")
public class FournisseurController<Fournisseur, Fournisseurs> {
#Autowired
private FournisseurRepository fournisseurRepository;
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long ID;
//get all employee
#GetMapping("/fournisseurs")
public java.util.List<net .javaguides.springboot.model.Fournisseur> getAllFournisseurs(){
return fournisseurRepository.findAll();
}
#PostMapping("/fournisseurs")
public Fournisseur createFournisseur(#RequestBody Fournisseur fournisseur){
return fournisseurRepository.save(fournisseur);
}
}
When running the application and use postman to post data it returns the following error:
{
"timestamp": "2021-12-13T22:06:19.958+00:00",
"status": 500,
"error": "Internal Server Error",
"trace": "java.lang.Error: Unresolved compilation problem: \n\tThe method save(S) in the type CrudRepository<Fournisseur,Long> is not applicable for the arguments (Fournisseur)\n\r\n\tat net.javaguides.springboot.controller.FournisseurController.createFournisseur(FournisseurController.java:33)\r\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)\r\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:568)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)\r\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:681)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:764)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)\r\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)\r\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)\r\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)\r\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\r\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)\r\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)\r\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382)\r\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\r\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722)\r\n\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\r\n\tat org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)\r\n\tat org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)\r\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\r\n\tat java.base/java.lang.Thread.run(Thread.java:833)\r\n",
"message": "Unresolved compilation problem: \n\tThe method save(S) in the type CrudRepository<Fournisseur,Long> is not applicable for the arguments (Fournisseur)\n",
"path": "/api/v1/fournisseurs"
}
And the IDE returns the following:
23:06:03.283 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader#33c8d704
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m [2m (v2.6.1)[0;39m
[2m2021-12-13 23:06:03.538[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mn.j.springboot.StockApplication [0;39m [2m:[0;39m Starting StockApplication using Java 17 on DESKTOP-BNFECFD with PID 19252 (C:\STS\Stock\target\classes started by ACER in C:\STS\Stock)
[2m2021-12-13 23:06:03.538[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mn.j.springboot.StockApplication [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2021-12-13 23:06:03.573[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36m.e.DevToolsPropertyDefaultsPostProcessor[0;39m [2m:[0;39m Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[2m2021-12-13 23:06:03.573[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36m.e.DevToolsPropertyDefaultsPostProcessor[0;39m [2m:[0;39m For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
[2m2021-12-13 23:06:03.966[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data JPA repositories in DEFAULT mode.
[2m2021-12-13 23:06:04.001[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 29 ms. Found 1 JPA repository interfaces.
[2m2021-12-13 23:06:04.374[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http)
[2m2021-12-13 23:06:04.380[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2021-12-13 23:06:04.381[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/9.0.55]
[2m2021-12-13 23:06:04.433[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2021-12-13 23:06:04.433[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 860 ms
[2m2021-12-13 23:06:04.528[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2021-12-13 23:06:04.628[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2021-12-13 23:06:04.655[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [name: default]
[2m2021-12-13 23:06:04.685[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36morg.hibernate.Version [0;39m [2m:[0;39m HHH000412: Hibernate ORM core version 5.6.1.Final
[2m2021-12-13 23:06:04.785[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.hibernate.annotations.common.Version [0;39m [2m:[0;39m HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
[2m2021-12-13 23:06:04.850[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36morg.hibernate.dialect.Dialect [0;39m [2m:[0;39m HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
[2m2021-12-13 23:06:05.150[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.h.e.t.j.p.i.JtaPlatformInitiator [0;39m [2m:[0;39m HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
[2m2021-12-13 23:06:05.156[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2021-12-13 23:06:05.324[0;39m [33m WARN[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mJpaBaseConfiguration$JpaWebConfiguration[0;39m [2m:[0;39m spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
[2m2021-12-13 23:06:05.512[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.d.a.OptionalLiveReloadServer [0;39m [2m:[0;39m LiveReload server is running on port 35729
[2m2021-12-13 23:06:05.605[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat started on port(s): 8080 (http) with context path ''
[2m2021-12-13 23:06:05.612[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mn.j.springboot.StockApplication [0;39m [2m:[0;39m Started StockApplication in 2.323 seconds (JVM running for 3.142)
[2m2021-12-13 23:06:19.900[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring DispatcherServlet 'dispatcherServlet'
[2m2021-12-13 23:06:19.900[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Initializing Servlet 'dispatcherServlet'
[2m2021-12-13 23:06:19.901[0;39m [32m INFO[0;39m [35m19252[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed initialization in 1 ms
[2m2021-12-13 23:06:19.954[0;39m [31mERROR[0;39m [35m19252[0;39m [2m---[0;39m [2m[nio-8080-exec-2][0;39m [36mo.a.c.c.C.[.[.[/].[dispatcherServlet] [0;39m [2m:[0;39m Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.Error: Unresolved compilation problem:
The method save(S) in the type CrudRepository<Fournisseur,Long> is not applicable for the arguments (Fournisseur)
] with root cause
java.lang.Error: Unresolved compilation problem:
The method save(S) in the type CrudRepository<Fournisseur,Long> is not applicable for the arguments (Fournisseur)
at net.javaguides.springboot.controller.FournisseurController.createFournisseur(FournisseurController.java:33) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.13.jar:5.3.13]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681) ~[tomcat-embed-core-9.0.55.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.13.jar:5.3.13]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.55.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
In the video am following for this example the same code worked. I did some researches and it is possible to create a custom save method, i tried it but always got the same result, in addition it is not recommended to do so. Is there any issue with my class??
I just changed the controller create fournisseur by:
//Create Fournisseur
#PostMapping("/fournisseurs")
public net.javaguides.springboot.model.Fournisseur createFournisseur(#RequestBody net.javaguides.springboot.model.Fournisseur fournisseur){
#SuppressWarnings("unused")
net.javaguides.springboot.model.Fournisseur updateFournisseur = fournisseurRepository.save(fournisseur);
return fournisseurRepository.save(fournisseur);
}
and it works :D

Error in running SpringBoot application at localhost : Error creating bean with name 'entityManagerFactory'

I started learning SpringBoot (using spring sts IDE) and trying to send values from a form & then save them to the database, for now, I have just created a simple form(using JSP) & bean class and checking if localhost shows a fallback error page i.e. page not found because I don't have created any controller to map the JSP page. But I am getting this Error creating bean with name 'entityManagerFactor'
My code:
user.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="addUsers">
<input type="text" name="id"/><br/>
<input type="text" name="name"/><br/>
<input type="submit"/><br/>
</form>
</body>
</html>
=============================================================
Users.java
package com.pdc2.users.model;
public class Users {
private int id;
private String name;
public Users() {
super();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Override
public String toString() {
return "Users [id=" + id + ", name=" + name + "]";
}
}
================================================================
POM.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.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.pdc2</groupId>
<artifactId>users</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>users</name>
<description>Customer Tracker</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>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
====================
main class (UsersApplication.java)
package com.pdc2.users;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class UsersApplication {
public static void main(String[] args) {
SpringApplication.run(UsersApplication.class, args);
}
}
===========================================================================================
Error:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m [2m (v2.5.5)[0;39m
[2m2021-10-16 13:15:24.523[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.pdc2.users.UsersApplication [0;39m [2m:[0;39m Starting UsersApplication using Java 16.0.2 on APL-B44W563 with PID 26068 (C:\Users\GA20099173\Documents\workspace-springBoot\users\target\classes started by GA20099173 in C:\Users\GA20099173\Documents\workspace-springBoot\users)
[2m2021-10-16 13:15:24.526[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.pdc2.users.UsersApplication [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2021-10-16 13:15:25.211[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data JPA repositories in DEFAULT mode.
[2m2021-10-16 13:15:25.230[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 6 ms. Found 0 JPA repository interfaces.
[2m2021-10-16 13:15:25.714[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http)
[2m2021-10-16 13:15:25.723[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2021-10-16 13:15:25.723[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/9.0.53]
[2m2021-10-16 13:15:25.890[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2021-10-16 13:15:25.890[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 1306 ms
[2m2021-10-16 13:15:26.058[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2021-10-16 13:15:26.253[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2021-10-16 13:15:26.302[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [name: default]
[2m2021-10-16 13:15:26.355[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36morg.hibernate.Version [0;39m [2m:[0;39m HHH000412: Hibernate ORM core version 5.4.32.Final
[2m2021-10-16 13:15:26.358[0;39m [33m WARN[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mConfigServletWebServerApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: 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 java.lang.NoClassDefFoundError: net/bytebuddy/NamingStrategy$SuffixingRandom$BaseNameResolver
[2m2021-10-16 13:15:26.358[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Shutdown initiated...
[2m2021-10-16 13:15:26.360[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mcom.zaxxer.hikari.HikariDataSource [0;39m [2m:[0;39m HikariPool-1 - Shutdown completed.
[2m2021-10-16 13:15:26.362[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Stopping service [Tomcat]
[2m2021-10-16 13:15:26.372[0;39m [32m INFO[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2021-10-16 13:15:26.390[0;39m [31mERROR[0;39m [35m26068[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed
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 java.lang.NoClassDefFoundError: net/bytebuddy/NamingStrategy$SuffixingRandom$BaseNameResolver
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.5.jar:2.5.5]
at com.pdc2.users.UsersApplication.main(UsersApplication.java:10) ~[classes/:na]
Caused by: java.lang.NoClassDefFoundError: net/bytebuddy/NamingStrategy$SuffixingRandom$BaseNameResolver
at org.hibernate.cfg.Environment.buildBytecodeProvider(Environment.java:345) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.cfg.Environment.buildBytecodeProvider(Environment.java:337) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.cfg.Environment.<clinit>(Environment.java:230) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$MergedSettings.<init>(EntityManagerFactoryBuilderImpl.java:1355) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$MergedSettings.<init>(EntityManagerFactoryBuilderImpl.java:1345) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.mergeSettings(EntityManagerFactoryBuilderImpl.java:478) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:217) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:168) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:52) ~[spring-orm-5.3.10.jar:5.3.10]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.10.jar:5.3.10]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.10.jar:5.3.10]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.10.jar:5.3.10]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.10.jar:5.3.10]
... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: net.bytebuddy.NamingStrategy$SuffixingRandom$BaseNameResolver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[na:na]
... 31 common frames omitted
Maven dependencies already present
Maven dependencies already present

propertySources Shows Empty (Spring Cloud Config)

I am trying to learn Spring Cloud. So I created a new project using Spring Starter (a very basic one)
I configured my application.properties like so:
server.port=9090
spring.cloud.config.server.native.searchLocations=file://H:/opt/app/app.static.properties
spring.profiles.active=native
But when I start my Spring Boot application, it starts fine (from what I can say), but when I hit URL http://localhost:9090/config/default/master
I get the output on the browser:
{"name":"config","profiles":["default"],"label":"master","version":null,"state":null,"propertySources":[]}
My Console output is:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m [2m (v2.5.2)[0;39m
[2m2021-07-09 20:28:59.573[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mcom.example.demo.DemoApplication [0;39m [2m:[0;39m Starting DemoApplication using Java 1.8.0_281 on HVDIVD17CA50359 with PID 30936 (H:\git\develop\demo\target\classes started by sm187t in H:\git\develop\demo)
[2m2021-07-09 20:28:59.583[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mcom.example.demo.DemoApplication [0;39m [2m:[0;39m The following profiles are active: native
[2m2021-07-09 20:28:59.909[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36m.e.DevToolsPropertyDefaultsPostProcessor[0;39m [2m:[0;39m Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[2m2021-07-09 20:29:06.725[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.cloud.context.scope.GenericScope [0;39m [2m:[0;39m BeanFactory id=374f6c33-f58f-370c-bb56-bdf932b163cb
[2m2021-07-09 20:29:09.167[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 9090 (http)
[2m2021-07-09 20:29:09.204[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.apache.catalina.core.StandardService [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2021-07-09 20:29:09.204[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/9.0.48]
[2m2021-07-09 20:29:09.677[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2021-07-09 20:29:09.678[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 9764 ms
[2m2021-07-09 20:29:10.197[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.w.s.ServletContextInitializerBeans[0;39m [2m:[0;39m Mapping filters: filterRegistrationBean urls=[/*] order=-2147483647, springSecurityFilterChain urls=[/*] order=-100, characterEncodingFilter urls=[/*] order=-2147483648, formContentFilter urls=[/*] order=-9900, requestContextFilter urls=[/*] order=-105
[2m2021-07-09 20:29:10.197[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.w.s.ServletContextInitializerBeans[0;39m [2m:[0;39m Mapping servlets: dispatcherServlet urls=[/]
[2m2021-07-09 20:29:11.354[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerAdapter[0;39m [2m:[0;39m ControllerAdvice beans: 0 #ModelAttribute, 0 #InitBinder, 1 RequestBodyAdvice, 1 ResponseBodyAdvice
[2m2021-07-09 20:29:12.124[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m 23 mappings in 'requestMappingHandlerMapping'
[2m2021-07-09 20:29:12.275[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.w.s.handler.SimpleUrlHandlerMapping [0;39m [2m:[0;39m Patterns [/webjars/**, /**] in 'resourceHandlerMapping'
[2m2021-07-09 20:29:12.309[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36m.m.m.a.ExceptionHandlerExceptionResolver[0;39m [2m:[0;39m ControllerAdvice beans: 0 #ExceptionHandler, 1 ResponseBodyAdvice
[2m2021-07-09 20:29:13.756[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.a.e.web.EndpointLinksResolver [0;39m [2m:[0;39m Exposing 1 endpoint(s) beneath base path '/actuator'
[2m2021-07-09 20:29:13.787[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.s.web.DefaultSecurityFilterChain [0;39m [2m:[0;39m Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#33b379d5, org.springframework.security.web.context.SecurityContextPersistenceFilter#701d0f6c, org.springframework.security.web.header.HeaderWriterFilter#255f44df, org.springframework.web.filter.CorsFilter#32abf174, org.springframework.security.web.csrf.CsrfFilter#5019771a, org.springframework.security.web.authentication.logout.LogoutFilter#74f8b524, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#2364f95a, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#53fb9109, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#64e99fc9, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#54704c84, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#334cbd88, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#7e74ddeb, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#6033bddc, org.springframework.security.web.session.SessionManagementFilter#1b3eed50, org.springframework.security.web.access.ExceptionTranslationFilter#4d7a1b8f, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#4590bbf6]
[2m2021-07-09 20:29:14.137[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.d.a.OptionalLiveReloadServer [0;39m [2m:[0;39m LiveReload server is running on port 35729
[2m2021-07-09 20:29:15.000[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/] [0;39m [2m:[0;39m Initializing Spring DispatcherServlet 'dispatcherServlet'
[2m2021-07-09 20:29:15.001[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Initializing Servlet 'dispatcherServlet'
[2m2021-07-09 20:29:15.002[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Detected StandardServletMultipartResolver
[2m2021-07-09 20:29:15.002[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Detected AcceptHeaderLocaleResolver
[2m2021-07-09 20:29:15.002[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Detected FixedThemeResolver
[2m2021-07-09 20:29:15.007[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator#611461
[2m2021-07-09 20:29:15.008[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Detected org.springframework.web.servlet.support.SessionFlashMapManager#7077db3
[2m2021-07-09 20:29:15.008[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
[2m2021-07-09 20:29:15.009[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[on(3)-127.0.0.1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed initialization in 8 ms
[2m2021-07-09 20:29:15.888[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat started on port(s): 9090 (http) with context path ''
[2m2021-07-09 20:29:16.252[0;39m [32m INFO[0;39m [35m30936[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mcom.example.demo.DemoApplication [0;39m [2m:[0;39m Started DemoApplication in 19.628 seconds (JVM running for 24.074)
[2m2021-07-09 20:29:30.465[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[nio-9090-exec-1][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped to org.springframework.cloud.config.server.environment.EnvironmentController#labelled(String, String, String)
[2m2021-07-09 20:29:30.522[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[nio-9090-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m GET "/config/default/master", parameters={}
[2m2021-07-09 20:29:30.526[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[nio-9090-exec-1][0;39m [36ms.w.s.m.m.a.RequestMappingHandlerMapping[0;39m [2m:[0;39m Mapped to org.springframework.cloud.config.server.environment.EnvironmentController#labelled(String, String, String)
[2m2021-07-09 20:29:30.994[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[nio-9090-exec-1][0;39m [36mm.m.a.RequestResponseBodyMethodProcessor[0;39m [2m:[0;39m Using 'application/json;q=0.8', given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8] and supported [application/json]
[2m2021-07-09 20:29:31.004[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[nio-9090-exec-1][0;39m [36mm.m.a.RequestResponseBodyMethodProcessor[0;39m [2m:[0;39m Writing [Environment [name=config, profiles=[default], label=master, propertySources=[], version=null, state= (truncated)...]
[2m2021-07-09 20:29:31.063[0;39m [32mDEBUG[0;39m [35m30936[0;39m [2m---[0;39m [2m[nio-9090-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed 200 OK
Shouldn't the propertySources be full of the property file entries? I am new to this. So mostly learning from tutorials and guides. Is my understanding correct?
Any help would be appreciated. Thanks.
The searchLocations property accepts a location of files and/or sub-directories.
try spring.cloud.config.server.native.searchLocations=file://H:/opt/app/ instead of spring.cloud.config.server.native.searchLocations=file://H:/opt/app/app.static.properties
and hit http://localhost:9090/config/default/master/app.static.properties
I got the same error followed the below steps.
Application properties is as below:
spring.application.name=spring-cloud-config-server
server.port=8888
logging.level.web=DEBUG
spring.cloud.config.server.git.uri=file:///C:/Users/DELL/git-localconfig-repo
Added dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
In limits-service pom.xml file
If it still does not work, try to delete limits-service.properties and create a new one, or else try creating limits-service-dev.properties, limits-service-prod.properties and call them by URLs http://localhost:8888/limits-service/dev and check if those work ..
Issue is mostly i guess with path or file name.
If you created the file using a notepad, it will put the extension of the file like limits-service.properties.txt , instead you need the file name limits-service.properties . I tried renaming the file from CMD and it worked .
rename limits-service.properties.txt to limits-service.properties
Try adding prop spring.cloud.config.server.git.searchPaths. This will tell spring in which path your property files are.
spring.profiles.active=git
spring.cloud.config.server.git.uri=https://gitlab.com/<project-name>/<app-name>.git
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.default-label=main
spring.cloud.config.server.git.username=git-username
spring.cloud.config.server.git.password=your-access-token-from-git
spring.cloud.config.server.git.searchPaths=path*

Resources