17 changed files with 192 additions and 123 deletions
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
/* |
||||
* Copyright 2012-2014 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.cli.command; |
||||
|
||||
/** |
||||
* An example that can be displayed in the help. |
||||
* |
||||
* @author Phillip Webb |
||||
* @since 1.2.0 |
||||
*/ |
||||
public class HelpExample { |
||||
|
||||
private final String description; |
||||
|
||||
private final String example; |
||||
|
||||
/** |
||||
* @param description The description (in the form "to ....") |
||||
* @param example the example |
||||
*/ |
||||
public HelpExample(String description, String example) { |
||||
this.description = description; |
||||
this.example = example; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return this.description; |
||||
} |
||||
|
||||
public String getExample() { |
||||
return this.example; |
||||
} |
||||
} |
||||
@ -1,61 +0,0 @@
@@ -1,61 +0,0 @@
|
||||
Spring Boot uses Servet 3.0 APIs to initialize the `ServletContext` |
||||
(register `Servlets` etc.) so you can't use the same application out |
||||
of the box in a Servlet 2.5 container. It *is* however possible to run |
||||
a Spring Boot application on an older container with some special |
||||
tools. If you include `org.springframework.boot:spring-boot-legacy` as |
||||
a dependency |
||||
(https://github.com/scratches/spring-boot-legacy[maintained |
||||
separately] to the core of Spring Boot and currently available at |
||||
1.0.0.RELEASE), all you should need to do is create a `web.xml` and |
||||
declare a context listener to create the application context and your |
||||
filters and servlets. The context listener is a special purpose one |
||||
for Spring Boot, but the rest of it is normal for a Spring application |
||||
in Servlet 2.5. Example: |
||||
|
||||
[source,xml,indent=0] |
||||
---- |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> |
||||
|
||||
<context-param> |
||||
<param-name>contextConfigLocation</param-name> |
||||
<param-value>demo.Application</param-value> |
||||
</context-param> |
||||
|
||||
<listener> |
||||
<listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class> |
||||
</listener> |
||||
|
||||
<filter> |
||||
<filter-name>metricFilter</filter-name> |
||||
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> |
||||
</filte>r |
||||
|
||||
<filter-mapping> |
||||
<filter-name>metricFilter</filter-name> |
||||
<url-pattern>/*</url-pattern> |
||||
</filter-mapping> |
||||
|
||||
<servlet> |
||||
<servlet-name>appServlet</servlet-name> |
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> |
||||
<init-param> |
||||
<param-name>contextAttribute</param-name> |
||||
<param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value> |
||||
</init-param> |
||||
<load-on-startup>1</load-on-startup> |
||||
</servlet> |
||||
|
||||
<servlet-mapping> |
||||
<servlet-name>appServlet</servlet-name> |
||||
<url-pattern>/</url-pattern> |
||||
</servlet-mapping> |
||||
|
||||
</web-app> |
||||
---- |
||||
|
||||
In this example we are using a single application context (the one created by the context listener) and |
||||
attaching it to the `DispatcherServlet` using an init parameter. This is normal in a Spring Boot |
||||
application (you normally only have one application conext). |
||||
Loading…
Reference in new issue