我正在尝试构建一个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
我想知道这样做是否有意义。如果我设法构建了应用程序,我是否能够生成代码,或者应用程序是否连接到其他地方来检索生成代码所需的数据?
我很感激你的提示。谢谢
2条答案
按热度按时间jdg4fx2g1#
我会在这里写下我的(潜在的)答案,尽管我真的不认为这是一个真正的答案,但太大了,不能作为一个评论。
所以我去https://github.com/spring-io/start.spring.io克隆了它。
然后我进入克隆项目的根目录并运行以下命令:
在这里,我在运行测试时遇到了一些错误,但这不应该太悲惨-我认为它们对我来说失败了,因为它尝试运行一些gradlew命令,但它们确实失败了,因为我的PC上没有安装Gradle,因为我一直在使用Gradle Wrapper。
然后我启动了Spring Boot应用程序。
Spring Boot应用程序已启动:
如果我现在调用http://localhost:8080/-它工作了,我什么也没做。
可能是您的JDK吗?我的意思是JDK相似但不相同...您还问:
我想知道这样做是否有意义。如果我成功构建了应用程序,我是否能够生成代码,或者应用程序是否连接到其他地方以检索生成代码所需的数据?我将非常感谢任何提示。谢谢
我个人认为,这可能是有意义的,但是-当我在我自己的Spring Initializr上生成一个项目时,我观察了Spring Boot应用程序的控制台,可以看到以下日志:
第一个月
看起来,这个东西实际上是从互联网上获取数据的,现在我不知道你有什么选择,但我有两个想法。
1.你可以尝试派生GitHub项目并尝试删除这个网络调用(如果这真的是唯一的一个)-至少在日志中我看不到更多的东西...调用的实际响应看起来很简单:
1.您明确允许URL https://spring.io/project_metadata/spring-boot在您的Air Gap网络内部获取数据(我不知道这是否可行)
希望这能帮上忙?
anauzrmj2#
有很多依赖项都是从spring-boot的初始化器开始的。如果你试图在一个空气间隙的网络中构建,你将无法访问maven的依赖项库。尝试在网络之外构建包,并捕获所需的库。在你的~/.m2/文件夹中查找所需库的副本。我建议设置一个Nexus库。当你需要的时候,它会从一个开放的网络中获取这些库,然后你可以在有空气间隙的网络中使用它们。
如果这是一个安全的网络,那么在你将所有这些文件放入这个有空气间隙的网络之前,你必须对它们进行审查和扫描。
当你添加额外的注解或依赖项时,你必须再次从maven central获取它们,这并不理想,但你可能会发现有人设置一个项目来包含所有的spring-boot依赖项。
此外,使用STS开发环境,并构建您的spring-boot以运行包含的库。