我使用 JHipster 生成了我的第一个微服务。为此,我使用了下面列出的 jdl 文件。现在我想在本地启动服务。
为此,我执行以下命令:
docker-compose -f myApp\src\main\docker\jhipster-registry.yml up -d
cd myApp
mvnw
似乎我没有考虑一些基本的东西。因为我收到以下错误消息:
:: JHipster ? :: Running Spring Boot 2.5.5 ::
:: https://www.jhipster.tech ::
2021-10-25 18:05:34.817 INFO 13520 --- [ main] com.myapp.MyApp : No active profile set, falling back to default profiles: dev,api-docs
2021-10-25 18:05:38.855 DEBUG 13520 --- [ main] i.g.r.utils.RxJava2OnClasspathCondition : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:38.904 DEBUG 13520 --- [ main] i.g.r.utils.RxJava2OnClasspathCondition : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:38.951 DEBUG 13520 --- [ main] i.g.r.utils.RxJava2OnClasspathCondition : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:38.994 DEBUG 13520 --- [ main] i.g.r.utils.RxJava2OnClasspathCondition : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:39.024 DEBUG 13520 --- [ main] i.g.r.utils.RxJava2OnClasspathCondition : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:41.654 WARN 13520 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration' defined in file [C:\Users\kleinoth\IdeaProjects\JHipster\microservicesTest\myApp\target\classes\com\myapp\config\SecurityConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService' defined in file [C:\Users\kleinoth\IdeaProjects\JHipster\microservicesTest\myApp\target\classes\com\myapp\security\DomainUserDetailsService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in com.myapp.repository.UserRepository defined in @EnableR2dbcRepositories declared on DatabaseConfiguration: Cannot create inner bean '(inner bean)#7b7cf475' of type [org.springframework.data.repository.core.support.RepositoryFragmentsFactoryBean] while setting bean property 'repositoryFragments'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#7b7cf475': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepositoryInternalImplFragment': Cannot resolve reference to bean 'userRepositoryInternalImpl' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRepositoryInternalImpl' defined in file [C:\Users\kleinoth\IdeaProjects\JHipster\microservicesTest\myApp\target\classes\com\myapp\repository\UserRepositoryInternalImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'r2dbcDatabaseClient' defined in class path resource [org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryDependentConfiguration.class]: Unsatisfied dependency expressed through method 'r2dbcDatabaseClient' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations$Pool.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.r2dbc.pool.ConnectionPool]: Factory method 'connectionFactory' threw exception; nested exception is java.lang.IllegalStateException: Unable to create a ConnectionFactory for 'ConnectionFactoryOptions{options={driver=h2, protocol=file, database=./target/h2db/db/myapp;DB_CLOSE_DELAY=-1, host=., user=myApp}}'. Available drivers: [ postgresql, pool ]
2021-10-25 18:05:41.763 ERROR 13520 --- [ main] o.s.boot.SpringApplication : Application run failed
网关应用程序似乎无法连接到 H2 数据库。至少网关应用程序不应该运行吗?有谁知道我错过了什么?
JDL 文件:
application {
config {
baseName myApp,
applicationType gateway,
packageName com.myapp,
serverPort 8080,
authenticationType jwt,
prodDatabaseType postgresql,
clientFramework angularX
}
entities *
}
application {
config {
baseName myApp1,
applicationType microservice,
packageName com.myapp,
serverPort 8081,
authenticationType jwt,
prodDatabaseType postgresql,
}
entities A, B
}
application {
config {
baseName myApp2,
applicationType microservice,
packageName com.myapp,
serverPort 8082,
authenticationType jwt,
prodDatabaseType postgresql,
}
entities C
}
entity A {
name String
}
entity B {
location String
}
entity C {
}
entity D {}
relationship OneToMany {
A to B
}
更新:它只影响网关应用程序。所有微服务都在注册表中运行和识别。
pom.xml 中的依赖关系:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
<scope>test</scope>
</dependency>