Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法启动springboot应用程序-资源位置不能为null_Spring_Spring Boot - Fatal编程技术网

无法启动springboot应用程序-资源位置不能为null

无法启动springboot应用程序-资源位置不能为null,spring,spring-boot,Spring,Spring Boot,第一次尝试springboot,但我无法启动它。 我使用了示例应用程序: 我还修改了使用嵌入式jetty而不是tomcat,但仍然没有成功 我得到的例外是:org.springframework.context.ApplicationContextException:无法启动嵌入式容器;嵌套异常为java.lang.IllegalArgumentException:资源位置不能为null 这是在MacOSX上 编辑:我已经确认这是一个环境问题。我可以在linux(fedora)虚拟机上很好地启动

第一次尝试springboot,但我无法启动它。 我使用了示例应用程序: 我还修改了使用嵌入式jetty而不是tomcat,但仍然没有成功

我得到的例外是:org.springframework.context.ApplicationContextException:无法启动嵌入式容器;嵌套异常为java.lang.IllegalArgumentException:资源位置不能为null

这是在MacOSX上

编辑:我已经确认这是一个环境问题。我可以在linux(fedora)虚拟机上很好地启动应用程序,但不管出于什么原因,我在Mac上遇到了这个问题。不确定是否有其他人遇到了这件事,并且对可能导致这件事的原因有任何线索

编辑2:因此,在默认情况下尝试配置ssl时,这似乎是一个问题。我不知道为什么会这样,因为我没有在任何地方具体说明这一点;所以我现在的问题是,如何在SpringBoot中禁用https

mvn -version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T09:29:23-08:00)
Maven home: /usr/local/Cellar/maven/3.2.5/libexec
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
感谢您的帮助

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.IllegalArgumentException: Resource location must not be null
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at hello.Application.main(Application.java:15) [classes!/:0.1.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [gs-spring-boot-0.1.0.jar:0.1.0]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [gs-spring-boot-0.1.0.jar:0.1.0]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [gs-spring-boot-0.1.0.jar:0.1.0]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [gs-spring-boot-0.1.0.jar:0.1.0]
Caused by: java.lang.IllegalArgumentException: Resource location must not be null
    at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.util.ResourceUtils.getURL(ResourceUtils.java:131) ~[spring-core-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureSslKeyStore(TomcatEmbeddedServletContainerFactory.java:417) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureSsl(TomcatEmbeddedServletContainerFactory.java:395) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.customizeSsl(TomcatEmbeddedServletContainerFactory.java:332) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.customizeConnector(TomcatEmbeddedServletContainerFactory.java:311) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:169) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    ... 16 common frames omitted
添加:
server.ssl.enabled=false
在我的application.properties中解决了这个问题。我假设ssl配置是基于父引导启动器pom的预期配置??同样,我也不知道为什么这在linux虚拟机中运行良好。
没有时间深入探讨这个问题,也许其他人可以透露更多信息。

我一直在禁用和启用HTTPS(
server.ssl.enabled=true
),但忘了将这些添加回来:

server.ssl.key-store=file:///Users/...
server.ssl.key-store-password=******

将来可能会对某些人有所帮助。

当我启用了
ssl.enabled:true
但没有设置其他ssl参数(因为YAML文件中的缩进错误)。这就是它在正常工作时在config/application.yaml中的外观

environments:
  production:
    server:
      port: 9080
      ssl:
        enabled: true
        key-store: /home/peter/app/ucast.rewara.com/ucast.rewara.com.cert.jks
        key-store-password: drowssapekaf
        key-password: ewerw23121sdsd
        key-alias: ucast.rewara.com
    grails:
      serverURL: "https://ucast.rewara.com:9080"`

这可能有助于某人:

任何ssl配置都可能导致这种情况,在我的情况下,我有以下剩余配置:

server.ssl.protocol=TLS
server.ssl.enabled-protocols=TLSv1.2

删除这些选项修复了该问题

我想您可以在application.properties文件中进行配置

#SSL:
server.ssl.enabled=false
如果你想建立本地的。它不会强制您提供SSL的关联证书(http://)

否则您将使用ssl->true在远程服务器(https://)中编译->请粘贴整个堆栈跟踪堆栈跟踪显示您的应用程序仍在使用Tomcat。看起来您正在尝试配置SSL,但配置不完整。一个完整的例子再现了这个问题,这将使我们更容易弄清楚到底发生了什么。同意嵌入式服务器上的@AndyWilkinson仍然是tomcat而不是Jetty。我试图在这里找到spring核心依赖项的根异常“Resource location must not null”——第131行。您的应用程序在类路径中似乎缺少(一些必要的!?)资源。希望你能从那里得到一个解决方法。@AndyWilkinson堆栈跟踪是在我使用jetty做任何更改之前。我在默认项目中遇到了这个问题。我正在做的一步一步:git克隆在gs-spring-boot/complete中,mvn包&java-jar-target/gs-spring-boot-0.1.0.jar仅此而已。@satya我也这么认为(关于资源),但没有关于我可能需要什么样的资源的其他信息。我还查看了ResourceUtils.java,但这无助于阐明这一点。@AndyWilkinson我已确认这是一个环境问题。我可以在linux虚拟机上很好地启动应用程序,但无论出于何种原因,我在Mac上遇到了这个问题。我猜你的Mac有一个环境变量或类似的变量,试图配置SSL