Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
为spring引导rest应用程序启用https_Https_Spring Boot - Fatal编程技术网

为spring引导rest应用程序启用https

为spring引导rest应用程序启用https,https,spring-boot,Https,Spring Boot,当使用https部署时,如何使spring引导应用程序能够访问? 我找到了一个解决方案,上面说将以下内容添加到application-config.xml文件 <security:http auto-config="true" create-session="stateless"> <security:intercept-url pattern="/**" access="ROLE_USER" requires-chan

当使用https部署时,如何使spring引导应用程序能够访问? 我找到了一个解决方案,上面说将以下内容添加到application-config.xml文件

   <security:http auto-config="true" create-session="stateless">
         <security:intercept-url pattern="/**" access="ROLE_USER"
                 requires-channel="https" />                      
          <security:http-basic />
   </security:http>

除了web.xml,我没有这个文件

<?xml version="1.0" encoding="UTF-8"?>
  <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        
xmlns:web="http://java.sun.com/xml/ns/javaee" 
xmlns="
http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/
xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml,
    /WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener- class>
 </listener>
<listener>
<listener-class>
    org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>api</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>api</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
              org.springframework.web.filter.DelegatingFilterProxy
    </filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

上下文配置位置
/WEB-INF/spring/root-context.xml,
/WEB-INF/spring/appServlet/servlet-context.xml
org.springframework.web.context.ContextLoaderListener
org.springframework.web.context.request.RequestContextListener
应用程序编程接口
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/spring/appServlet/servlet-context.xml
1.
应用程序编程接口
/
默认HTMLescape
真的
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*

Spring引导支持SSL配置属性(在application.yaml|properties中)

您可以使用TomcatEmbeddedServletContainerFactory执行相同的操作

server.port=8443
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-password=secret
server.ssl.key-password=another-secret