This commit is contained in:
darya 2024-11-15 01:04:14 +04:00
parent 2f859b0495
commit 5309fd92e8
27 changed files with 2994 additions and 1826 deletions

View File

@ -4,21 +4,31 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="67d3f0b7-2fd3-4b40-a135-0347e30e6207" name="Changes" comment="add log file">
<change afterPath="$PROJECT_DIR$/minio/src/main/java/com/spring/minio/config/KafkaConsumerConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/minio/src/main/java/com/spring/minio/consumer/Consumer.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/minio/src/main/java/com/spring/minio/properties/KafkaProperties.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/report/src/main/java/com/spring/report/config/KafkaProducerConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/report/src/main/java/com/spring/report/kafka/Producer.java" afterDir="false" />
<list default="true" id="67d3f0b7-2fd3-4b40-a135-0347e30e6207" name="Changes" comment="lw5">
<change afterPath="$PROJECT_DIR$/dcaa/src/main/java/com/spring/dcaa/config/OpenApiConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dcaa/src/main/resources/db/changelog/changeset/create-users-table.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/controller/AuthController.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/dto/AuthRequest.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/error/GlobalExceptionHandler.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/error/UnauthorizedException.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/filter/JwtFilter.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/model/Role.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/model/User.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/repository/UserRepository.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/service/AuthUtil.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/service/JwtUtil.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/gateway/src/main/java/com/spring/gateway/service/UserService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dcaa/src/main/resources/db/changelog/db.changelog-master.xml" beforeDir="false" afterPath="$PROJECT_DIR$/dcaa/src/main/resources/db/changelog/db.changelog-master.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docker-compose.yml" beforeDir="false" afterPath="$PROJECT_DIR$/docker-compose.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gateway/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/gateway/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gateway/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/gateway/src/main/resources/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/minio/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/minio/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/minio/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/minio/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/minio/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/minio/src/main/resources/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/minio/src/main/java/com/spring/minio/consumer/Consumer.java" beforeDir="false" afterPath="$PROJECT_DIR$/minio/src/main/java/com/spring/minio/consumer/Consumer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/minio/src/main/java/com/spring/minio/controller/MinioController.java" beforeDir="false" afterPath="$PROJECT_DIR$/minio/src/main/java/com/spring/minio/controller/MinioController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/report/logs/application.log" beforeDir="false" afterPath="$PROJECT_DIR$/report/logs/application.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/report/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/report/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/report/src/main/java/com/spring/report/controller/VisitorController.java" beforeDir="false" afterPath="$PROJECT_DIR$/report/src/main/java/com/spring/report/controller/VisitorController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/report/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/report/src/main/resources/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/report/src/main/java/com/spring/report/kafka/Producer.java" beforeDir="false" afterPath="$PROJECT_DIR$/report/src/main/java/com/spring/report/kafka/Producer.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -46,11 +56,12 @@
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"Docker.docker-compose.yml.postgres: Compose Deployment.executor": "Run",
"Docker.docker-compose.yml: Compose Deployment.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "lw5",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "D:/java/DemoTaskMediasoft(2)",
"last_opened_file_path": "D:/java/dcaa-mcs",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@ -67,7 +78,7 @@
<recent name="D:\java\dcaa-mcs\dcaa\src\main\resources" />
</key>
</component>
<component name="RunManager">
<component name="RunManager" selected="Docker.docker-compose.yml.postgres: Compose Deployment">
<configuration default="true" type="docker-deploy" factoryName="docker-compose.yml" temporary="true">
<deployment type="docker-compose.yml">
<settings />
@ -82,8 +93,22 @@
</deployment>
<method v="2" />
</configuration>
<configuration name="docker-compose.yml.postgres: Compose Deployment" type="docker-deploy" factoryName="docker-compose.yml" temporary="true" server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="services">
<list>
<option value="postgres" />
</list>
</option>
<option name="sourceFilePath" value="docker-compose.yml" />
</settings>
</deployment>
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Docker.docker-compose.yml.postgres: Compose Deployment" />
<item itemvalue="Docker.docker-compose.yml: Compose Deployment" />
</list>
</recent_temporary>
@ -108,7 +133,8 @@
<workItem from="1729199229123" duration="2034000" />
<workItem from="1729271426421" duration="377000" />
<workItem from="1729706571244" duration="12931000" />
<workItem from="1729789297391" duration="5967000" />
<workItem from="1729789297391" duration="7392000" />
<workItem from="1731614556569" duration="3561000" />
</task>
<task id="LOCAL-00001" summary="add minio">
<option name="closed" value="true" />
@ -126,7 +152,15 @@
<option name="project" value="LOCAL" />
<updated>1729725028044</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="lw5">
<option name="closed" value="true" />
<created>1729797106713</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1729797106713</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -147,6 +181,7 @@
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="add minio" />
<MESSAGE value="add log file" />
<option name="LAST_COMMIT_MESSAGE" value="add log file" />
<MESSAGE value="lw5" />
<option name="LAST_COMMIT_MESSAGE" value="lw5" />
</component>
</project>

297
dcaa/logs/application.log Normal file
View File

@ -0,0 +1,297 @@
2024-11-14 23:56:59 [main] INFO c.s.d.DistributedComputingAndApplicationsApplication - Starting DistributedComputingAndApplicationsApplication using Java 17.0.8 with PID 4632 (D:\java\dcaa-mcs\dcaa\target\classes started by amaya in D:\java\dcaa-mcs\dcaa)
2024-11-14 23:56:59 [main] INFO c.s.d.DistributedComputingAndApplicationsApplication - No active profile set, falling back to 1 default profile: "default"
2024-11-14 23:57:00 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-11-14 23:57:00 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 66 ms. Found 1 JPA repository interface.
2024-11-14 23:57:01 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port 8080 (http)
2024-11-14 23:57:01 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
2024-11-14 23:57:01 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
2024-11-14 23:57:01 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.28]
2024-11-14 23:57:01 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2024-11-14 23:57:01 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1876 ms
2024-11-14 23:57:01 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2024-11-14 23:57:02 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@58a7dc4
2024-11-14 23:57:02 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2024-11-14 23:57:02 [main] INFO liquibase.database - Set default schema name to public
2024-11-14 23:57:03 [main] INFO liquibase.changelog - Reading from public.databasechangelog
2024-11-14 23:57:03 [main] INFO liquibase.lockservice - Successfully acquired change log lock
2024-11-14 23:57:03 [main] INFO liquibase.command - Using deploymentId: 1614223376
2024-11-14 23:57:03 [main] INFO liquibase.changelog - Reading from public.databasechangelog
2024-11-14 23:57:03 [main] INFO liquibase.ui - Running Changeset: db/changelog/changeset/create-users-table.xml::create-users-table::darya
2024-11-14 23:57:03 [main] ERROR liquibase.changelog - ChangeSet db/changelog/changeset/create-users-table.xml::create-users-table::darya encountered an exception.
liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:473)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:80)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:182)
at liquibase.executor.AbstractExecutor.execute(AbstractExecutor.java:141)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1176)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:764)
at liquibase.changelog.visitor.UpdateVisitor.executeAcceptedChange(UpdateVisitor.java:119)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:68)
at liquibase.changelog.ChangeLogIterator$2.lambda$run$0(ChangeLogIterator.java:133)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.changelog.ChangeLogIterator$2.run(ChangeLogIterator.java:122)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.Scope.child(Scope.java:256)
at liquibase.Scope.child(Scope.java:260)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:89)
at liquibase.command.core.AbstractUpdateCommandStep.lambda$run$0(AbstractUpdateCommandStep.java:112)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.command.core.AbstractUpdateCommandStep.run(AbstractUpdateCommandStep.java:110)
at liquibase.command.core.UpdateCommandStep.run(UpdateCommandStep.java:105)
at liquibase.command.CommandScope.execute(CommandScope.java:219)
at liquibase.Liquibase.lambda$update$0(Liquibase.java:245)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.Liquibase.runInScope(Liquibase.java:1436)
at liquibase.Liquibase.update(Liquibase.java:234)
at liquibase.Liquibase.update(Liquibase.java:212)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:297)
at liquibase.integration.spring.SpringLiquibase.lambda$afterPropertiesSet$0(SpringLiquibase.java:249)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.Scope.child(Scope.java:256)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:242)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1802)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:954)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
at com.spring.dcaa.DistributedComputingAndApplicationsApplication.main(DistributedComputingAndApplicationsApplication.java:10)
Caused by: org.postgresql.util.PSQLException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2725)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2412)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:371)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:502)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:419)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:341)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:326)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:302)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:297)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:467)
... 63 common frames omitted
2024-11-14 23:57:03 [main] INFO liquibase.util - UPDATE SUMMARY
2024-11-14 23:57:03 [main] INFO liquibase.util - Run: 0
2024-11-14 23:57:03 [main] INFO liquibase.util - Previously run: 1
2024-11-14 23:57:03 [main] INFO liquibase.util - Filtered out: 0
2024-11-14 23:57:03 [main] INFO liquibase.util - -------------------------------
2024-11-14 23:57:03 [main] INFO liquibase.util - Total change sets: 1
2024-11-14 23:57:03 [main] INFO liquibase.util - Update summary generated
2024-11-14 23:57:03 [main] INFO liquibase.command - Update command encountered an exception.
2024-11-14 23:57:03 [main] INFO liquibase.lockservice - Successfully released change log lock
2024-11-14 23:57:03 [main] INFO liquibase.command - Logging exception.
2024-11-14 23:57:03 [main] INFO liquibase.ui - ERROR: Exception Details
2024-11-14 23:57:03 [main] INFO liquibase.ui - ERROR: Exception Primary Class: PSQLException
2024-11-14 23:57:03 [main] INFO liquibase.ui - ERROR: Exception Primary Reason: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44
2024-11-14 23:57:03 [main] INFO liquibase.ui - ERROR: Exception Primary Source: PostgreSQL 16.0
2024-11-14 23:57:03 [main] INFO liquibase.command - Command execution complete
2024-11-14 23:57:03 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - 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]: Failed to initialize dependency 'liquibase' of LoadTimeWeaverAware bean 'entityManagerFactory': Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/changeset/create-users-table.xml::create-users-table::darya:
Reason: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
2024-11-14 23:57:03 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2024-11-14 23:57:03 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
2024-11-14 23:57:03 [main] INFO o.a.catalina.core.StandardService - Stopping service [Tomcat]
2024-11-14 23:57:03 [main] INFO o.s.b.a.l.ConditionEvaluationReportLogger -
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-11-14 23:57:03 [main] ERROR o.s.boot.SpringApplication - 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]: Failed to initialize dependency 'liquibase' of LoadTimeWeaverAware bean 'entityManagerFactory': Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/changeset/create-users-table.xml::create-users-table::darya:
Reason: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:326)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:954)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
at com.spring.dcaa.DistributedComputingAndApplicationsApplication.main(DistributedComputingAndApplicationsApplication.java:10)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/changeset/create-users-table.xml::create-users-table::darya:
Reason: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1806)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313)
... 10 common frames omitted
Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/changeset/create-users-table.xml::create-users-table::darya:
Reason: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:259)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1802)
... 17 common frames omitted
Caused by: liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/changeset/create-users-table.xml::create-users-table::darya:
Reason: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at liquibase.command.CommandScope.execute(CommandScope.java:257)
at liquibase.Liquibase.lambda$update$0(Liquibase.java:245)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.Liquibase.runInScope(Liquibase.java:1436)
at liquibase.Liquibase.update(Liquibase.java:234)
at liquibase.Liquibase.update(Liquibase.java:212)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:297)
at liquibase.integration.spring.SpringLiquibase.lambda$afterPropertiesSet$0(SpringLiquibase.java:249)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.Scope.child(Scope.java:256)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:242)
... 19 common frames omitted
Caused by: liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/changeset/create-users-table.xml::create-users-table::darya:
Reason: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:151)
at liquibase.command.core.AbstractUpdateCommandStep.lambda$run$0(AbstractUpdateCommandStep.java:112)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.command.core.AbstractUpdateCommandStep.run(AbstractUpdateCommandStep.java:110)
at liquibase.command.core.UpdateCommandStep.run(UpdateCommandStep.java:105)
at liquibase.command.CommandScope.execute(CommandScope.java:219)
... 35 common frames omitted
Caused by: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/changeset/create-users-table.xml::create-users-table::darya:
Reason: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:808)
at liquibase.changelog.visitor.UpdateVisitor.executeAcceptedChange(UpdateVisitor.java:119)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:68)
at liquibase.changelog.ChangeLogIterator$2.lambda$run$0(ChangeLogIterator.java:133)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.changelog.ChangeLogIterator$2.run(ChangeLogIterator.java:122)
at liquibase.Scope.lambda$child$0(Scope.java:190)
at liquibase.Scope.child(Scope.java:199)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:168)
at liquibase.Scope.child(Scope.java:256)
at liquibase.Scope.child(Scope.java:260)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:89)
... 43 common frames omitted
Caused by: liquibase.exception.DatabaseException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44 [Failed SQL: (0) CREATE TABLE public.users (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, role VARCHAR(255), CONSTRAINT users_pkey PRIMARY KEY (id))]
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:473)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:80)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:182)
at liquibase.executor.AbstractExecutor.execute(AbstractExecutor.java:141)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1176)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:764)
... 58 common frames omitted
Caused by: org.postgresql.util.PSQLException: ОШИБКА: функция uuid_generate_v4() не существует
Подсказка: Функция с данными именем и типами аргументов не найдена. Возможно, вам следует добавить явные приведения типов.
Позиция: 44
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2725)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2412)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:371)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:502)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:419)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:341)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:326)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:302)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:297)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94)
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:467)
... 63 common frames omitted
2024-11-14 23:58:12 [main] INFO c.s.d.DistributedComputingAndApplicationsApplication - Starting DistributedComputingAndApplicationsApplication using Java 17.0.8 with PID 9916 (D:\java\dcaa-mcs\dcaa\target\classes started by amaya in D:\java\dcaa-mcs\dcaa)
2024-11-14 23:58:12 [main] INFO c.s.d.DistributedComputingAndApplicationsApplication - No active profile set, falling back to 1 default profile: "default"
2024-11-14 23:58:13 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-11-14 23:58:13 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 47 ms. Found 1 JPA repository interface.
2024-11-14 23:58:14 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port 8080 (http)
2024-11-14 23:58:14 [main] INFO o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
2024-11-14 23:58:14 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
2024-11-14 23:58:14 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.28]
2024-11-14 23:58:14 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2024-11-14 23:58:14 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1463 ms
2024-11-14 23:58:14 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2024-11-14 23:58:14 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@1de13f34
2024-11-14 23:58:14 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2024-11-14 23:58:14 [main] INFO liquibase.database - Set default schema name to public
2024-11-14 23:58:15 [main] INFO liquibase.changelog - Reading from public.databasechangelog
2024-11-14 23:58:15 [main] INFO liquibase.lockservice - Successfully acquired change log lock
2024-11-14 23:58:15 [main] INFO liquibase.command - Using deploymentId: 1614295434
2024-11-14 23:58:15 [main] INFO liquibase.changelog - Reading from public.databasechangelog
2024-11-14 23:58:15 [main] INFO liquibase.ui - Running Changeset: db/changelog/changeset/create-users-table.xml::create-users-table::darya
2024-11-14 23:58:15 [main] INFO liquibase.changelog - Table users created
2024-11-14 23:58:15 [main] INFO liquibase.changelog - ChangeSet db/changelog/changeset/create-users-table.xml::create-users-table::darya ran successfully in 29ms
2024-11-14 23:58:15 [main] INFO liquibase.util - UPDATE SUMMARY
2024-11-14 23:58:15 [main] INFO liquibase.util - Run: 1
2024-11-14 23:58:15 [main] INFO liquibase.util - Previously run: 1
2024-11-14 23:58:15 [main] INFO liquibase.util - Filtered out: 0
2024-11-14 23:58:15 [main] INFO liquibase.util - -------------------------------
2024-11-14 23:58:15 [main] INFO liquibase.util - Total change sets: 2
2024-11-14 23:58:15 [main] INFO liquibase.util - Update summary generated
2024-11-14 23:58:15 [main] INFO liquibase.command - Update command completed successfully.
2024-11-14 23:58:15 [main] INFO liquibase.ui - Liquibase: Update has been successful. Rows affected: 1
2024-11-14 23:58:15 [main] INFO liquibase.lockservice - Successfully released change log lock
2024-11-14 23:58:15 [main] INFO liquibase.command - Command execution complete
2024-11-14 23:58:15 [main] INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default]
2024-11-14 23:58:15 [main] INFO org.hibernate.Version - HHH000412: Hibernate ORM core version 6.5.2.Final
2024-11-14 23:58:15 [main] INFO o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled
2024-11-14 23:58:16 [main] INFO o.s.o.j.p.SpringPersistenceUnitInfo - No LoadTimeWeaver setup: ignoring JPA class transformer
2024-11-14 23:58:16 [main] WARN org.hibernate.orm.deprecation - HHH90000025: PostgreSQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-11-14 23:58:17 [main] INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2024-11-14 23:58:17 [main] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
2024-11-14 23:58:17 [main] INFO o.s.d.j.r.query.QueryEnhancerFactory - Hibernate is in classpath; If applicable, HQL parser will be used.
2024-11-14 23:58:17 [main] WARN o.s.b.a.o.j.JpaBaseConfiguration$JpaWebConfiguration - 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
2024-11-14 23:58:18 [main] INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"]
2024-11-14 23:58:18 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port 8080 (http) with context path '/'
2024-11-14 23:58:18 [main] INFO c.s.d.DistributedComputingAndApplicationsApplication - Started DistributedComputingAndApplicationsApplication in 6.217 seconds (process running for 6.906)
2024-11-14 23:58:26 [SpringApplicationShutdownHook] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
2024-11-14 23:58:26 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2024-11-14 23:58:26 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.

View File

@ -0,0 +1,28 @@
package com.spring.dcaa.config;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@OpenAPIDefinition(info = @Info(title = "Rental API", version = "v1"))
public class OpenApiConfig {
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.addServersItem(new Server().url("http://localhost:6060/rental"))
.addSecurityItem(new SecurityRequirement().addList("Bearer"))
.components(new io.swagger.v3.oas.models.Components()
.addSecuritySchemes("Bearer", new SecurityScheme()
.name("Authorization")
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")));
}
}

View File

@ -0,0 +1,21 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
<changeSet id="create-users-table" author="darya">
<createTable tableName="users">
<column name="id" type="uuid">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="email" type="varchar(255)">
<constraints nullable="false"/>
</column>
<column name="password" type="varchar(255)">
<constraints nullable="false"/>
</column>
<column name="role" type="varchar(255)">
<constraints nullable="true"/>
</column>
</createTable>
</changeSet>
</databaseChangeLog>

View File

@ -4,4 +4,5 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
<include file="/db/changelog/changeset/create-visitors-table.xml"/>
<include file="/db/changelog/changeset/create-users-table.xml"/>
</databaseChangeLog>

View File

@ -7,6 +7,10 @@ services:
image: gateway
ports:
- "6060:6060"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/Rental
SPRING_DATASOURCE_USERNAME: role_for_spring
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD}
networks:
backend:
aliases:

View File

@ -0,0 +1,99 @@
2024-11-15 00:35:46 [background-preinit] INFO o.h.validator.internal.util.Version - HV000001: Hibernate Validator 8.0.1.Final
2024-11-15 00:35:46 [main] INFO c.spring.gateway.GatewayApplication - Starting GatewayApplication using Java 21.0.1 with PID 6048 (D:\java\dcaa-mcs\gateway\target\classes started by amaya in D:\java\dcaa-mcs\gateway)
2024-11-15 00:35:46 [main] INFO c.spring.gateway.GatewayApplication - No active profile set, falling back to 1 default profile: "default"
2024-11-15 00:35:48 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-11-15 00:35:49 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 208 ms. Found 1 JPA repository interface.
2024-11-15 00:35:49 [main] INFO o.s.cloud.context.scope.GenericScope - BeanFactory id=4cd63aab-9820-3caf-9964-cc499267ba55
2024-11-15 00:35:50 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2024-11-15 00:35:50 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@506aa618
2024-11-15 00:35:50 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2024-11-15 00:35:50 [main] INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default]
2024-11-15 00:35:50 [main] INFO org.hibernate.Version - HHH000412: Hibernate ORM core version 6.5.3.Final
2024-11-15 00:35:50 [main] INFO o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled
2024-11-15 00:35:51 [main] INFO o.s.o.j.p.SpringPersistenceUnitInfo - No LoadTimeWeaver setup: ignoring JPA class transformer
2024-11-15 00:35:51 [main] WARN org.hibernate.orm.deprecation - HHH90000021: Encountered deprecated setting [hibernate.temp.use_jdbc_metadata_defaults], use [hibernate.boot.allow_jdbc_metadata_access] instead
2024-11-15 00:35:51 [main] WARN org.hibernate.orm.deprecation - HHH90000025: PostgreSQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-11-15 00:35:56 [main] INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2024-11-15 00:35:56 [main] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
2024-11-15 00:35:58 [main] INFO o.s.cloud.commons.util.InetUtils - Cannot determine local hostname
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [After]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Before]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Between]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Cookie]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Header]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Host]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Method]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Path]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Query]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [ReadBody]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [RemoteAddr]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [XForwardedRemoteAddr]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Weight]
2024-11-15 00:35:58 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [CloudFoundryRouteService]
2024-11-15 00:36:01 [main] INFO o.s.cloud.commons.util.InetUtils - Cannot determine local hostname
2024-11-15 00:36:03 [main] WARN o.s.b.w.r.c.AnnotationConfigReactiveWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
2024-11-15 00:36:03 [main] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
2024-11-15 00:36:03 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2024-11-15 00:36:03 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
2024-11-15 00:36:03 [main] INFO o.s.b.a.l.ConditionEvaluationReportLogger -
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-11-15 00:36:03 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 6060 was already in use.
Action:
Identify and stop the process that's listening on port 6060 or configure this application to listen on another port.
2024-11-15 00:36:45 [background-preinit] INFO o.h.validator.internal.util.Version - HV000001: Hibernate Validator 8.0.1.Final
2024-11-15 00:36:45 [main] INFO c.spring.gateway.GatewayApplication - Starting GatewayApplication using Java 21.0.1 with PID 20292 (D:\java\dcaa-mcs\gateway\target\classes started by amaya in D:\java\dcaa-mcs\gateway)
2024-11-15 00:36:45 [main] INFO c.spring.gateway.GatewayApplication - No active profile set, falling back to 1 default profile: "default"
2024-11-15 00:36:47 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-11-15 00:36:47 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 189 ms. Found 1 JPA repository interface.
2024-11-15 00:36:47 [main] INFO o.s.cloud.context.scope.GenericScope - BeanFactory id=4cd63aab-9820-3caf-9964-cc499267ba55
2024-11-15 00:36:48 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2024-11-15 00:36:48 [main] INFO com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@40f1aa95
2024-11-15 00:36:48 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2024-11-15 00:36:48 [main] INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default]
2024-11-15 00:36:48 [main] INFO org.hibernate.Version - HHH000412: Hibernate ORM core version 6.5.3.Final
2024-11-15 00:36:48 [main] INFO o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled
2024-11-15 00:36:49 [main] INFO o.s.o.j.p.SpringPersistenceUnitInfo - No LoadTimeWeaver setup: ignoring JPA class transformer
2024-11-15 00:36:49 [main] WARN org.hibernate.orm.deprecation - HHH90000021: Encountered deprecated setting [hibernate.temp.use_jdbc_metadata_defaults], use [hibernate.boot.allow_jdbc_metadata_access] instead
2024-11-15 00:36:49 [main] WARN org.hibernate.orm.deprecation - HHH90000025: PostgreSQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-11-15 00:36:50 [main] INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2024-11-15 00:36:50 [main] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
2024-11-15 00:36:52 [main] INFO o.s.cloud.commons.util.InetUtils - Cannot determine local hostname
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [After]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Before]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Between]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Cookie]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Header]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Host]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Method]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Path]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Query]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [ReadBody]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [RemoteAddr]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [XForwardedRemoteAddr]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [Weight]
2024-11-15 00:36:52 [main] INFO o.s.c.g.r.RouteDefinitionRouteLocator - Loaded RoutePredicateFactory [CloudFoundryRouteService]
2024-11-15 00:36:55 [main] INFO o.s.cloud.commons.util.InetUtils - Cannot determine local hostname
2024-11-15 00:36:55 [main] INFO o.s.b.w.e.netty.NettyWebServer - Netty started on port 6061 (http)
2024-11-15 00:36:56 [main] INFO o.s.cloud.commons.util.InetUtils - Cannot determine local hostname
2024-11-15 00:36:57 [main] INFO o.s.cloud.commons.util.InetUtils - Cannot determine local hostname
2024-11-15 00:36:57 [main] INFO c.spring.gateway.GatewayApplication - Started GatewayApplication in 13.51 seconds (process running for 15.11)
2024-11-15 00:40:04 [reactor-http-nio-1] INFO c.s.g.f.CorrelationTrackingPreFilter - Tracking filter invoked...
2024-11-15 00:40:04 [reactor-http-nio-1] INFO c.s.g.f.CorrelationTrackingPreFilter - Generated new correlation id: 51ba480f-411b-41c4-8ace-501bf8a0313e
2024-11-15 00:40:04 [reactor-http-nio-1] INFO c.s.g.f.CorrelationTrackingPostFilter - Injecting correlation id: 51ba480f-411b-41c4-8ace-501bf8a0313e
2024-11-15 00:42:30 [HikariPool-1 housekeeper] WARN com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Thread starvation or clock leap detected (housekeeper delta=2m41s953ms938µs100ns).
2024-11-15 00:42:30 [reactor-http-nio-1] INFO c.s.g.f.CorrelationTrackingPostFilter - Response status code: 500 INTERNAL_SERVER_ERROR
2024-11-15 00:42:47 [SpringApplicationShutdownHook] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
2024-11-15 00:42:47 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2024-11-15 00:42:47 [SpringApplicationShutdownHook] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.

View File

@ -44,11 +44,48 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.12.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.12.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.12.5</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>

View File

@ -0,0 +1,27 @@
package com.spring.gateway.controller;
import com.spring.gateway.dto.AuthRequest;
import com.spring.gateway.service.AuthUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
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;
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthController {
private final AuthUtil authUtil;
@PostMapping("/register")
public ResponseEntity<String> register(@RequestBody AuthRequest req) {
return ResponseEntity.ok(authUtil.signUp(req));
}
@PostMapping("/login")
public ResponseEntity<String> login(@RequestBody AuthRequest req) {
return ResponseEntity.ok(authUtil.signIn(req));
}
}

View File

@ -0,0 +1,15 @@
package com.spring.gateway.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class AuthRequest {
private String email;
private String password;
}

View File

@ -0,0 +1,20 @@
package com.spring.gateway.error;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.server.ResponseStatusException;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(ResponseStatusException.class)
public ResponseEntity<String> handleResponseStatusException(ResponseStatusException ex) {
return ResponseEntity.status(ex.getStatusCode()).body(ex.getReason());
}
@ExceptionHandler(Exception.class)
public ResponseEntity<String> handleUnknownException(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ex.getMessage());
}
}

View File

@ -0,0 +1,14 @@
package com.spring.gateway.error;
import org.springframework.http.HttpStatus;
import org.springframework.web.server.ResponseStatusException;
public class UnauthorizedException extends ResponseStatusException {
public UnauthorizedException() {
super(HttpStatus.UNAUTHORIZED, "Unauthorized");
}
public UnauthorizedException(String message) {
super(HttpStatus.UNAUTHORIZED, message);
}
}

View File

@ -0,0 +1,58 @@
package com.spring.gateway.filter;
import com.spring.gateway.error.UnauthorizedException;
import com.spring.gateway.model.User;
import com.spring.gateway.service.JwtUtil;
import com.spring.gateway.service.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.util.Optional;
@Slf4j
@Component
@RequiredArgsConstructor
public class JwtFilter implements GlobalFilter, Ordered {
private final JwtUtil jwtUtil;
private final UserService userService;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
final String uri = request.getURI().toString();
if (uri.startsWith("/auth") || uri.contains("swagger") || uri.contains("api-docs")) {
return chain.filter(exchange);
}
if (!request.getHeaders().containsKey("Authorization")) {
throw new UnauthorizedException();
}
String token = request.getHeaders().getOrEmpty("Authorization").get(0).substring(7);
try {
if (jwtUtil.isExpired(token)) {
throw new UnauthorizedException();
}
} catch (Exception ex) {
throw new UnauthorizedException();
}
String email = jwtUtil.getSubject(token);
Optional<User> user = userService.find(email);
if (user.isPresent()) {
return chain.filter(exchange);
} else {
throw new UnauthorizedException();
}
}
@Override
public int getOrder() {
return 0;
}
}

View File

@ -0,0 +1,6 @@
package com.spring.gateway.model;
public enum Role {
USER,
ADMIN,
}

View File

@ -0,0 +1,28 @@
package com.spring.gateway.model;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.UUID;
@Entity
@Table(name="users")
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class User {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
private String email;
private String password;
private Role role;
}

View File

@ -0,0 +1,11 @@
package com.spring.gateway.repository;
import com.spring.gateway.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
import java.util.UUID;
public interface UserRepository extends JpaRepository<User, UUID> {
Optional<User> findByEmail(String email);
}

View File

@ -0,0 +1,35 @@
package com.spring.gateway.service;
import com.spring.gateway.dto.AuthRequest;
import com.spring.gateway.model.Role;
import com.spring.gateway.model.User;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class AuthUtil {
private final UserService userService;
private final JwtUtil jwtUtil;
private final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
public String signUp(AuthRequest req) {
userService.create(
req.getEmail(),
passwordEncoder.encode(req.getPassword()),
Role.USER
);
return "Success";
}
public String signIn(AuthRequest req) {
final User user = userService.find(req.getEmail())
.orElseThrow(() -> new RuntimeException("Incorrect email or password"));
if (!passwordEncoder.matches(req.getPassword(), user.getPassword())) {
throw new RuntimeException("Incorrect email or password");
}
return jwtUtil.generateToken(user);
}
}

View File

@ -0,0 +1,55 @@
package com.spring.gateway.service;
import com.spring.gateway.model.User;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.crypto.SecretKey;
import java.util.Date;
import java.util.function.Function;
@Service
public class JwtUtil {
@Value("${jwt.secret-key}")
private String SECRET_KEY;
public String generateToken(User user) {
final int expiration = 1000 * 60 * 60; // 1h
return Jwts.builder()
.subject(user.getEmail())
.issuedAt(new Date(System.currentTimeMillis()))
.expiration(new Date(System.currentTimeMillis() + expiration))
.signWith(getSignInKey(), Jwts.SIG.HS256)
.compact();
}
public boolean isExpired(String token) {
return extractClaim(token, Claims::getExpiration).before(new Date());
}
public String getSubject(String token) {
return extractClaim(token, Claims::getSubject);
}
private SecretKey getSignInKey() {
byte[] keyBytes = Decoders.BASE64.decode(SECRET_KEY);
return Keys.hmacShaKeyFor(keyBytes);
}
private <T> T extractClaim(String token, Function<Claims, T> claimsResolver) {
final Claims claims = extractAllClaims(token);
return claimsResolver.apply(claims);
}
private Claims extractAllClaims(String token) {
return Jwts.parser()
.verifyWith(getSignInKey())
.build()
.parseSignedClaims(token)
.getPayload();
}
}

View File

@ -0,0 +1,24 @@
package com.spring.gateway.service;
import com.spring.gateway.model.Role;
import com.spring.gateway.model.User;
import com.spring.gateway.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
@RequiredArgsConstructor
public class UserService {
private final UserRepository userRepository;
public User create(String email, String password, Role role) {
final User user = new User(null, email, password, role);
return userRepository.save(user);
}
public Optional<User> find(String email) {
return userRepository.findByEmail(email);
}
}

View File

@ -14,15 +14,32 @@ spring:
filters:
- RewritePath=/rental/(?<path>.*), /$\{path}
- RemoveRequestHeader=Cookie,Set-Cookie
# - id: report
# uri: http://report:8082
# predicates:
# - Path=/report/**
# filters:
# - RewritePath=/report/(?<path>.*), /$\{path}
# - RemoveRequestHeader=Cookie,Set-Cookie
- id: minio
uri: http://myminio:8081
predicates:
- Path=/minio/**
filters:
- RewritePath=/minio/(?<path>.*), /${path}
- RemoveRequestHeader=Cookie,Set-Cookie
datasource:
url: jdbc:postgresql://localhost:5432/Rental
username: role_for_spring
password: ${DB_PASSWORD}
driver-class-name: org.postgresql.Driver
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
show_sql: true
ddl-auto: validate
temp:
use_jdbc_metadata_defaults: false
management:
endpoint:
end:
exposure:
include: "*"
jwt:
secret-key: 2e292e323124377c78255f363165246b6c7d684a7379445f5c3b713962

View File

@ -5,20 +5,17 @@
</component>
<component name="ChangeListManager">
<list default="true" id="4c468ddb-7fbe-40b8-bf97-16a0c944e8c6" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/com/spring/minio/config/KafkaConsumerConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/spring/minio/consumer/Consumer.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/com/spring/minio/properties/KafkaProperties.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../report/src/main/java/com/spring/report/config/KafkaProducerConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../report/src/main/java/com/spring/report/kafka/Producer.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../gateway/src/main/java/com/spring/gateway/config/SecurityConfig.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../gateway/src/main/java/com/spring/gateway/filter/JwtAuthFilter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../docker-compose.yml" beforeDir="false" afterPath="$PROJECT_DIR$/../docker-compose.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../gateway/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../gateway/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/../gateway/src/main/resources/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/spring/minio/consumer/Consumer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/spring/minio/consumer/Consumer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/spring/minio/controller/MinioController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/spring/minio/controller/MinioController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../report/logs/application.log" beforeDir="false" afterPath="$PROJECT_DIR$/../report/logs/application.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../report/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../report/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../report/src/main/java/com/spring/report/controller/VisitorController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../report/src/main/java/com/spring/report/controller/VisitorController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../report/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/../report/src/main/resources/application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../report/src/main/java/com/spring/report/kafka/Producer.java" beforeDir="false" afterPath="$PROJECT_DIR$/../report/src/main/java/com/spring/report/kafka/Producer.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -75,7 +72,7 @@
"Spring Boot.MinioApplication.executor": "Run",
"git-widget-placeholder": "lw5",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "D:/учеба/диплом/protege",
"last_opened_file_path": "D:/java",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@ -155,7 +152,10 @@
<workItem from="1729271678576" duration="138000" />
<workItem from="1729432602672" duration="627000" />
<workItem from="1729705852820" duration="15757000" />
<workItem from="1729795093249" duration="1693000" />
<workItem from="1729795093249" duration="2507000" />
<workItem from="1729940091457" duration="4875000" />
<workItem from="1729959483684" duration="1816000" />
<workItem from="1730073394292" duration="173000" />
</task>
<servers />
</component>

View File

@ -4,6 +4,8 @@ import com.spring.minio.config.MinioAdapter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Service;
@Slf4j
@ -18,10 +20,10 @@ public class Consumer {
* @param message Сообщение, полученное из Kafka.
*/
@KafkaListener(topics = "test_topic", containerFactory = "kafkaListenerContainerFactory")
public void listenGroupTopic(byte[] message) {
log.info("Received message");
public void listenGroupTopic(byte[] message, @Header(KafkaHeaders.RECEIVED_KEY) String key) {
log.info("Received message with cor-id: " + key);
try {
minioAdapter.uploadFile("user1", "visitors_report.csv", message);
minioAdapter.uploadFile("user1", key + " visitors_report.csv", message);
} catch (Exception e) {
log.error("Exception: ", e);

View File

@ -17,6 +17,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@ -55,7 +56,7 @@ public class MinioController {
}
@GetMapping("/download")
public ResponseEntity<?> get(@RequestPart("file") String file, @RequestHeader(CORRELATION_ID) String correlationId) {
public ResponseEntity<?> get(@RequestParam("file") String file, @RequestHeader(CORRELATION_ID) String correlationId) {
log.info(String.format("Trying get file | correlation-id: %s | endpoint: /download | method: GET", correlationId));
try {
byte[] data = minioAdapter.getFile("user1", file);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -87,7 +87,7 @@ public class VisitorController {
private void uploadFileToMinio(File file, String corId) {
try {
producer.sendEvent(Producer.TEST_TOPIC, Files.readAllBytes(file.toPath()));
producer.sendEvent(Producer.TEST_TOPIC, corId, Files.readAllBytes(file.toPath()));
} catch (Exception e) {
log.error("Error uploading file to Kafka", e);
}

View File

@ -16,11 +16,11 @@ public class Producer {
private final KafkaTemplate<String, byte[]> kafkaTemplateByteArray;
public static final String TEST_TOPIC = "test_topic";
public void sendEvent(final String topic, final byte[] data) {
public void sendEvent(final String topic, final String key, final byte[] data) {
Assert.hasText(topic, "topic must not be blank");
Assert.notNull(data, "data not be null");
CompletableFuture<SendResult<String, byte[]>> future = kafkaTemplateByteArray.send(topic, data);
CompletableFuture<SendResult<String, byte[]>> future = kafkaTemplateByteArray.send(topic, key, data);
future.whenComplete((result, ex) -> {
if (ex == null) {