网站的克隆start.spring.io

50few1ms  于 2022-12-23  发布在  Spring
关注(0)|答案(2)|浏览(98)

我正在尝试构建一个www.example.com的示例start.spring.io,以便在一个空气隔离的网络中使用它。我已经为此工作了三个星期,但我仍然不知道该怎么做。我已经从GitHub克隆了start.spring.io,并将其安装在一个连接到Internet的主机上。
在那里,我可以毫无错误地构建应用程序:

./mvnw clean install -DskipTests=true

然后,如果我运行应用程序(从start-site目录中../mwnw spring-boot:run),当应用程序启动时,我会得到以下错误,我的意思是,这不是一个尝试生成项目的错误,应用程序死亡:

2022-12-19 17:53:21.170  INFO 2701 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2022-12-19 17:53:21.264  WARN 2701 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [io.spring.initializr.web.controller.ProjectGenerationController] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902]
2022-12-19 17:53:21.272  INFO 2701 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-12-19 17:53:21.311  INFO 2701 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-12-19 17:53:21.411 ERROR 2701 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [io.spring.initializr.web.controller.ProjectGenerationController] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.23.jar:5.3.23]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.23.jar:5.3.23]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar:5.3.23]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$
...

因此,除了已经包含在项目中的依赖项之外,我没有添加任何特殊的依赖项或initilializr依赖项。我使用Bell Soft的Java 17。我不关心Sping Boot 版本,但我没有修改项目中的任何内容。顶层目录中的pom文件包括:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.5</version>
    </parent>

关于我的依赖关系,我使用的是initializer-bom:0.20.0-SNAPSHOT,我也尝试过其他版本,如0.13.0和0.12.0,但在这两种情况下构建start-site都失败:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /workspaces/start.spring.io.ori/start-site/src/main/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudContractKotlinDslGradleBuildCustomizer.java:[44,22] cannot find symbol
  symbol:   method snippets()
  location: variable build of type io.spring.initializr.generator.buildsystem.gradle.GradleBuild
[ERROR] /workspaces/start.spring.io.ori/start-site/src/main/java/io/spring/start/site/extension/dependency/graalvm/HibernatePluginGroovyDslGradleBuildCustomizer.java:[39,22] cannot find symbol
  symbol:   method snippets()
  location: variable build of type io.spring.initializr.generator.buildsystem.gradle.GradleBuild
[ERROR] /workspaces/start.spring.io.ori/start-site/src/main/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudContractGroovyDslGradleBuildCustomizer.java:[36,22] cannot find symbol
  symbol:   method snippets()
  location: variable build of type io.spring.initializr.generator.buildsystem.gradle.GradleBuild
[INFO] 3 errors

我想知道这样做是否有意义。如果我设法构建了应用程序,我是否能够生成代码,或者应用程序是否连接到其他地方来检索生成代码所需的数据?
我很感激你的提示。谢谢

jdg4fx2g

jdg4fx2g1#

我会在这里写下我的(潜在的)答案,尽管我真的不认为这是一个真正的答案,但太大了,不能作为一个评论。

所以我去https://github.com/spring-io/start.spring.io克隆了它。

git clone https://github.com/spring-io/start.spring.io.git

然后我进入克隆项目的根目录并运行以下命令:

./mvnw clean install

在这里,我在运行测试时遇到了一些错误,但这不应该太悲惨-我认为它们对我来说失败了,因为它尝试运行一些gradlew命令,但它们确实失败了,因为我的PC上没有安装Gradle,因为我一直在使用Gradle Wrapper。
然后我启动了Spring Boot应用程序。

cd start-site
../mvnw spring-boot:run

Spring Boot应用程序已启动:

022-12-20T15:01:03.510+01:00  INFO 16592 --- [  restartedMain] io.spring.start.site.StartApplication    : No active profile set, falling back to 1 default profile: "default"
2022-12-20T15:01:03.573+01:00  INFO 16592 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-12-20T15:01:03.573+01:00  INFO 16592 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-12-20T15:01:04.800+01:00  INFO 16592 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-12-20T15:01:04.809+01:00  INFO 16592 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-12-20T15:01:04.810+01:00  INFO 16592 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-12-20T15:01:04.872+01:00  INFO 16592 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-12-20T15:01:04.873+01:00  INFO 16592 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1298 ms
2022-12-20T15:01:05.371+01:00  INFO 16592 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2022-12-20T15:01:05.823+01:00  INFO 16592 --- [  restartedMain] org.ehcache.core.EhcacheManager          : Cache 'initializr.metadata' created in EhcacheManager.
2022-12-20T15:01:05.832+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.metadata
2022-12-20T15:01:05.832+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.metadata
2022-12-20T15:01:05.835+01:00  INFO 16592 --- [  restartedMain] org.ehcache.core.EhcacheManager          : Cache 'initializr.dependency-metadata' created in EhcacheManager.
2022-12-20T15:01:05.836+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.dependency-metadata
2022-12-20T15:01:05.836+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.dependency-metadata
2022-12-20T15:01:05.839+01:00  INFO 16592 --- [  restartedMain] org.ehcache.core.EhcacheManager          : Cache 'initializr.project-resources' created in EhcacheManager.
2022-12-20T15:01:05.841+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.project-resources
2022-12-20T15:01:05.841+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.project-resources
2022-12-20T15:01:05.843+01:00  INFO 16592 --- [  restartedMain] org.ehcache.core.EhcacheManager          : Cache 'initializr.templates' created in EhcacheManager.
2022-12-20T15:01:05.843+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheConfiguration,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.templates
2022-12-20T15:01:05.844+01:00  INFO 16592 --- [  restartedMain] org.ehcache.jsr107.Eh107CacheManager     : Registering Ehcache MBean javax.cache:type=CacheStatistics,CacheManager=urn.X-ehcache.jsr107-default-config,Cache=initializr.templates
2022-12-20T15:01:06.026+01:00  INFO 16592 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2022-12-20T15:01:06.031+01:00  INFO 16592 --- [  restartedMain] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2022-12-20T15:01:06.078+01:00  INFO 16592 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-12-20T15:01:06.089+01:00  INFO 16592 --- [  restartedMain] io.spring.start.site.StartApplication    : Started StartApplication in 3.056 seconds (process running for 3.444)
2022-12-20T15:01:17.890+01:00  INFO 16592 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-12-20T15:01:17.891+01:00  INFO 16592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-12-20T15:01:17.892+01:00  INFO 16592 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2022-12-20T15:01:18.122+01:00  INFO 16592 --- [io-8080-exec-10] .s.SaganInitializrMetadataUpdateStrategy : Fetching Spring Boot metadata from https://spring.io/project_metadata/spring-boot

如果我现在调用http://localhost:8080/-它工作了,我什么也没做。

可能是您的JDK吗?我的意思是JDK相似但不相同...您还问:
我想知道这样做是否有意义。如果我成功构建了应用程序,我是否能够生成代码,或者应用程序是否连接到其他地方以检索生成代码所需的数据?我将非常感谢任何提示。谢谢
我个人认为,这可能是有意义的,但是-当我在我自己的Spring Initializr上生成一个项目时,我观察了Spring Boot应用程序的控制台,可以看到以下日志:
第一个月
看起来,这个东西实际上是从互联网上获取数据的,现在我不知道你有什么选择,但我有两个想法。
1.你可以尝试派生GitHub项目并尝试删除这个网络调用(如果这真的是唯一的一个)-至少在日志中我看不到更多的东西...调用的实际响应看起来很简单:

{"id":"spring-boot","name":"Spring Boot","projectReleases":[{"version":"3.0.1-SNAPSHOT","versionDisplayName":"3.0.1-SNAPSHOT","current":false,"releaseStatus":"SNAPSHOT","snapshot":true},{"version":"3.0.0","versionDisplayName":"3.0.0","current":true,"releaseStatus":"GENERAL_AVAILABILITY","snapshot":false},{"version":"2.7.7-SNAPSHOT","versionDisplayName":"2.7.7-SNAPSHOT","current":false,"releaseStatus":"SNAPSHOT","snapshot":true},{"version":"2.7.6","versionDisplayName":"2.7.6","current":false,"releaseStatus":"GENERAL_AVAILABILITY","snapshot":false},{"version":"2.6.14","versionDisplayName":"2.6.14","current":false,"releaseStatus":"GENERAL_AVAILABILITY","snapshot":false},{"version":"2.5.14","versionDisplayName":"2.5.14","current":false,"releaseStatus":"GENERAL_AVAILABILITY","snapshot":false},{"version":"2.4.13","versionDisplayName":"2.4.13","current":false,"releaseStatus":"GENERAL_AVAILABILITY","snapshot":false}]}

1.您明确允许URL https://spring.io/project_metadata/spring-boot在您的Air Gap网络内部获取数据(我不知道这是否可行)
希望这能帮上忙?

anauzrmj

anauzrmj2#

有很多依赖项都是从spring-boot的初始化器开始的。如果你试图在一个空气间隙的网络中构建,你将无法访问maven的依赖项库。尝试在网络之外构建包,并捕获所需的库。在你的~/.m2/文件夹中查找所需库的副本。我建议设置一个Nexus库。当你需要的时候,它会从一个开放的网络中获取这些库,然后你可以在有空气间隙的网络中使用它们。
如果这是一个安全的网络,那么在你将所有这些文件放入这个有空气间隙的网络之前,你必须对它们进行审查和扫描。
当你添加额外的注解或依赖项时,你必须再次从maven central获取它们,这并不理想,但你可能会发现有人设置一个项目来包含所有的spring-boot依赖项。
此外,使用STS开发环境,并构建您的spring-boot以运行包含的库。

相关问题