spring boot 启动Word文档下载推荐.docx
- 文档编号:21179838
- 上传时间:2023-01-28
- 格式:DOCX
- 页数:16
- 大小:26.35KB
spring boot 启动Word文档下载推荐.docx
《spring boot 启动Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《spring boot 启动Word文档下载推荐.docx(16页珍藏版)》请在冰豆网上搜索。
2
12.
License,
or
(at
your
option)
any
later
version.
13.
14.
distributed
in
hope
that
will
be
useful,
15.
but
WITHOUT
ANY
WARRANTY;
without
even
implied
warranty
16.
MERCHANTABILITY
FITNESS
FOR
A
PARTICULAR
PURPOSE.
See
17.
for
more
details.
18.
19.
You
should
have
received
a
copy
20.
along
with
this
program.
If
not,
see
21.
<
http:
//www.gnu.org/licenses/gpl-2.0.html>
.
22.
#L%
23.
*/
24.
25.import
org.springframework.boot.SpringApplication;
26.import
org.springframework.boot.autoconfigure.EnableAutoConfiguration;
27.import
org.springframework.boot.builder.SpringApplicationBuilder;
28.import
org.springframework.boot.context.web.SpringBootServletInitializer;
29.import
org.springframework.boot.orm.jpa.EntityScan;
30.import
org.springframework.context.annotation.ComponentScan;
31.import
org.springframework.context.annotation.Configuration;
32.import
org.springframework.context.annotation.Import;
33.
34.@Configuration
35.@Import(net.gplatform.sudoor.server.Application.class)
36.@EnableAutoConfiguration
37.@ComponentScan
38.@EntityScan
39.public
class
Application
extends
SpringBootServletInitializer
{
40.
/*
41.
Used
spring
boot
42.
43.
public
static
void
main(String[]
args)
44.
SpringApplication.run(Application.class,
args);
45.
}
46.
47.
@Override
48.
protected
SpringApplicationBuilder
configure(SpringApplicationBuilder
application)
49.
return
application.sources(Application.class);
50.
51.
52.}
@Import(net.gplatform.sudoor.server.Application.class)
对应的模块:
net.gplatform.sudoor.server;
24.import
org.springframework.context.annotation.ImportResource;
org.springframework.data.jpa.repository.config.EnableJpaRepositories;
30.
31.@Configuration
32.@ImportResource({
"
classpath:
META-INF/cxf/cxf.xml"
META-INF/cxf/cxf-servlet.xml"
classpath*:
META-INF/cxf/cxf-extension-*.xml"
spring/**/*-config-*.xml"
})
34.@ComponentScan
35.//TODO:
Don'
t
support
multiple
config,
so
only
config
value.
Will
change
once
supported
36.@EntityScan({
net.gplatform.sudoor.server"
com.vcredit.jdev"
37.@EnableJpaRepositories({
38.public
39.
47.}
SpringBootServletInitializer:
1./*
Copyright
2012-2014
original
author
authors.
3.
Licensed
Apache
Version
2.0
(the
License"
);
may
not
use
file
except
compliance
License.
obtain
at
//www.apache.org/licenses/LICENSE-2.0
Unless
required
applicable
law
agreed
to
writing,
software
on
an
AS
IS"
BASIS,
WARRANTIES
OR
CONDITIONS
OF
KIND,
express
implied.
specific
language
governing
permissions
and
limitations
17.package
org.springframework.boot.context.web;
19.import
javax.servlet.ServletContext;
20.import
javax.servlet.ServletContextEvent;
21.import
javax.servlet.ServletException;
23.import
mons.logging.Log;
mons.logging.LogFactory;
org.springframework.boot.builder.ParentContextApplicationContextInitializer;
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
org.springframework.context.ApplicationContext;
org.springframework.web.WebApplicationInitializer;
org.springframework.web.context.ContextLoaderListener;
org.springframework.web.context.WebApplicationContext;
32.
33./**
34.
handy
opinionated
{@link
WebApplicationInitializer}
applications
starts
35.
Spring
Boot
application
lets
bind
servlet
filter
mappings.
36.
complicated
consider
using
one
other
37.
WebApplicationInitializers.
38.
p>
Note
WebApplicationInitializer
needed
if
are
building
war
deploying
it.
prefer
run
embedded
container
(we
do)
then
won'
need
all.
@author
Dave
Syer
45.public
abstract
implements
final
Log
logger
=
LogFactory.getLog(getClass());
onStartup(ServletContext
servletContext)
throws
ServletException
WebApplicationContext
rootAppContext
createRootApplicationContext(servletContext);
52.
(rootAppContext
!
null)
53.
servletContext.addListener(new
ContextLoaderListener(rootAppContext)
54.
55.
contextInitialized(ServletContextEvent
event)
56.
//
no-op
because
context
already
initialized
57.
58.
});
59.
60.
else
61.
this.logger.debug("
No
ContextLoaderListener
registered,
62.
+
createRootApplicationContext()
did
63.
context"
64.
65.
66.
67.
createRootApplicationContext(
68.
ServletContext
69.
ApplicationContext
parent
null;
70.
Object
object
servletContext
71.
.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
72.
(object
instanceof
ApplicationContext)
73.
this.logger.info("
Root
created
(using
parent)."
74.
(ApplicationContext)
object;
75.
servletContext.setAttribute(
76.
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
null);
77.
78.
new
SpringApplicationBuilder();
79.
(parent
80.
application.initializers(new
ParentContextApplicationContextInitializer(
81.
parent));
82.
83.
ServletContextApplicationContextInitializer(
84.
servletContext));
85.
application.contextClass(AnnotationConfigEmbeddedWebApplicationContext.class);
86.
configure(application);
87.
Ensure
error
pages
registered
88.
application.sources(ErrorPageFilter.class);
89.
(WebApplicationContext)
application.run();
90.
91.
92.
/**
93.
Configure
application.
Normally
all
would
do
add
sources
(e.g.
94.
classes)
settings
sensible
defaults.
might
choose
95.
(for
instance)
default
command
line
arguments,
set
active
96.
profile.
97.
@param
builder
98.
@see
99.
100.
101.
application;
102.
103.
104.}
1.WebApplicationInitializer
2002-2012
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- spring boot 启动
![提示](https://static.bdocx.com/images/bang_tan.gif)