- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试转动 this example在 Spring Boot 应用程序中,问题在于 RestfulServer
是一个 servlet,而且我并不是真的试图创建一个单独的应用程序,而是创建一个或多或少扩展该 servlet 的应用程序。我似乎遇到的问题是,我使用 WebApplicationInitializer
和 SpringBootApplicationInitializer
尝试过的事情是,它们在执行其他 @Configuration
之前没有初始化 servlet code> 类。如何将 JpaServerDemo
类转换为 Spring Boot?(注意:我们不需要第二个 servlet)
更新这是我尝试的最后一件事,但是我也尝试了WebApplicationInitializer
的各种迭代,或者在configure
方法中执行操作这看起来很棘手,因为它没有 servletContext
,并且 onStartup
没有 ApplicationContext
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
public void onStartup( ServletContext servletContext ) throws ServletException {
super.onStartup( servletContext );
RestfulServer server = new RestfulServer();
servletContext.addServlet( "restful", server );
/*
* We want to support FHIR DSTU3 format. This means that the server
* will use the DSTU3 bundle format and other DSTU3 encoding changes.
*
* If you want to use DSTU1 instead, change the following line, and change the 3 occurrences of dstu2 in web.xml to dstu1
*/
server.setFhirContext( FhirContext.forDstu3() );
WebApplicationContext myAppCtx = this.createRootApplicationContext( servletContext );
// Get the spring context from the web container (it's declared in web.xml)
/*
* The BaseJavaConfigDstu3.java class is a spring configuration
* file which is automatically generated as a part of hapi-fhir-jpaserver-base and
* contains bean definitions for a resource provider for each resource type
*/
List<IResourceProvider> beans = myAppCtx.getBean( "myResourceProvidersDstu3", List.class );
server.setResourceProviders( beans );
/*
* The system provider implements non-resource-type methods, such as
* transaction, and global history.
*/
server.setPlainProviders( myAppCtx.getBean( "mySystemProviderDstu3", JpaSystemProviderDstu3.class ) );
/*
* The conformance provider exports the supported resources, search parameters, etc for
* this server. The JPA version adds resource counts to the exported statement, so it
* is a nice addition.
*/
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean( "mySystemDaoDstu3", IFhirSystemDao.class );
DaoConfig daoConfig = myAppCtx.getBean( DaoConfig.class );
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3( server, systemDao, daoConfig );
confProvider.setImplementationDescription( "Example Server" );
server.setServerConformanceProvider( confProvider );
/*
* Enable ETag Support (this is already the default)
*/
server.setETagSupport( ETagSupportEnum.ENABLED );
/*
* This server tries to dynamically generate narratives
*/
FhirContext ctx = server.getFhirContext();
ctx.setNarrativeGenerator( new
DefaultThymeleafNarrativeGenerator() );
/*
* Default to JSON and pretty printing
*/
server.setDefaultPrettyPrint( true );
server.setDefaultResponseEncoding( EncodingEnum.JSON );
/*
* -- New in HAPI FHIR 1.5 --
* This configures the server to page search results to and from
* the database, instead of only paging them to memory. This may mean
* a performance hit when performing searches that return lots of results,
* but makes the server much more scalable.
*/
server.setPagingProvider( myAppCtx.getBean( DatabaseBackedPagingProvider.class ) );
/*
* Load interceptors for the server from Spring (these are defined in FhirServerConfig.java)
*/
Collection<IServerInterceptor> interceptorBeans = myAppCtx.getBeansOfType( IServerInterceptor.class ).values();
for (
IServerInterceptor interceptor : interceptorBeans )
{
server.registerInterceptor( interceptor );
}
/*
* If you are hosting this server at a specific DNS name, the server will try to
* figure out the FHIR base URL based on what the web container tells it, but
* this doesn't always work. If you are setting links in your search bundles that
* just refer to "localhost", you might want to use a server address strategy:
*/
//setServerAddressStrategy(new HardcodedServerAddressStrategy("http://example.com/fhir/baseDstu2"));
/*
* If you are using DSTU3+, you may want to add a terminology uploader, which allows
* uploading of external terminologies such as Snomed CT. Note that this uploader
* does not have any security attached (any anonymous user may use it by default)
* so it is a potential security vulnerability. Consider using an AuthorizationInterceptor
* with this feature.
*/
server.registerProvider( myAppCtx.getBean( TerminologyUploaderProviderDstu3.class ) );
}
@Override
protected SpringApplicationBuilder configure( final SpringApplicationBuilder builder ) {
return builder;
}
public static void main( String[] args ) {
configureApplication( new SpringApplicationBuilder() ).run( args );
}
private static SpringApplicationBuilder configureApplication( final SpringApplicationBuilder builder ) {
return builder.sources( Application.class );
}
}
最佳答案
这似乎有效,我将@WebServlet
添加到类中,并使用Spring 4.3的无注释构造函数注入(inject)功能注入(inject)WebApplicationContext
。我还将 @ServletComponentScan
添加到我的 Application
中,它位于同一包中
@WebServlet( "/fhir/*" )
public class FhirServlet extends RestfulServer {
private static final long serialVersionUID = 3341258540126825379L;
private final WebApplicationContext myAppCtx;
public FhirServlet( WebApplicationContext myAppCtx ) {
this.myAppCtx = myAppCtx;
}
@Override
protected void initialize() throws ServletException {
this.setFhirContext( FhirContext.forDstu3() );
this.setServerAddressStrategy( new IncomingRequestAddressStrategy() );
this.setDefaultPrettyPrint( true );
this.setDefaultResponseEncoding( EncodingEnum.JSON );
this.setETagSupport( ETagSupportEnum.ENABLED );
/*
* The BaseJavaConfigDstu3.java class is a spring configuration
* file which is automatically generated as a part of hapi-fhir-jpaserver-base and
* contains bean definitions for a resource provider for each resource type
*/
List<IResourceProvider> beans = myAppCtx.getBean( "myResourceProvidersDstu3", List.class );
setResourceProviders( beans );
/*
* The system provider implements non-resource-type methods, such as
* transaction, and global history.
*/
setPlainProviders( myAppCtx.getBean( "mySystemProviderDstu3", JpaSystemProviderDstu3.class ) );
/*
* The conformance provider exports the supported resources, search parameters, etc for
* this server. The JPA version adds resource counts to the exported statement, so it
* is a nice addition.
*/
IFhirSystemDao<Bundle, Meta> systemDao = myAppCtx.getBean( "mySystemDaoDstu3", IFhirSystemDao.class );
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3( this, systemDao, myAppCtx.getBean( DaoConfig.class ) );
confProvider.setImplementationDescription( "Example Server" );
setServerConformanceProvider( confProvider );
/*
* This server tries to dynamically generate narratives
*/
getFhirContext().setNarrativeGenerator( new DefaultThymeleafNarrativeGenerator() );
/*
* -- New in HAPI FHIR 1.5 --
* This configures the server to page search results to and from
* the database, instead of only paging them to memory. This may mean
* a performance hit when performing searches that return lots of results,
* but makes the server much more scalable.
*/
setPagingProvider( myAppCtx.getBean( DatabaseBackedPagingProvider.class ) );
/*
* Load interceptors for the server from Spring (these are defined in FhirServerConfig.java)
*/
Collection<IServerInterceptor> interceptorBeans = myAppCtx.getBeansOfType( IServerInterceptor.class ).values();
for ( IServerInterceptor interceptor : interceptorBeans ) {
this.registerInterceptor( interceptor );
}
/*
* If you are hosting this server at a specific DNS name, the server will try to
* figure out the FHIR base URL based on what the web container tells it, but
* this doesn't always work. If you are setting links in your search bundles that
* just refer to "localhost", you might want to use a server address strategy:
*/
//setServerAddressStrategy(new HardcodedServerAddressStrategy("http://example.com/fhir/baseDstu2"));
/*
* If you are using DSTU3+, you may want to add a terminology uploader, which allows
* uploading of external terminologies such as Snomed CT. Note that this uploader
* does not have any security attached (any anonymous user may use it by default)
* so it is a potential security vulnerability. Consider using an AuthorizationInterceptor
* with this feature.
*/
registerProvider( myAppCtx.getBean( TerminologyUploaderProviderDstu3.class ) );
}
}
关于java - 如何让我的 Spring Boot 应用程序基于外部 Servlet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41033123/
如何指示 webpack 排除所有 d3 模块? // does not work externals: { "d3-*": "d3" } 所以如果应用导入了d3-submod
这个问题在这里已经有了答案: 9年前关闭。 Possible Duplicate: What does “outer =>” really mean? 我在哪里可以找到有关信息 trait After
这是一个简单的循环,我正在尝试对性能进行基准测试。 var extremeLoop=function(n){ var time=new Date() var t=0; for(
问题+概述 下面是两个片段,其中包含最初隐藏的 div,然后通过单击 button 和 jQuery 的 .show() 显示。两个 div 都具有由外部样式表应用的 display: grid; 样
我有一个 HTML 页面和一个单独的 .js 文件,该文件包含在带有 的页面中标签。 这是我的 .js 文件: element = document.getElementById("test");
我在 linux 静态库项目中有 3 个文件,我想在两个类方法实现文件中使用的静态字段存在链接问题。我有 class1.h、class1main.cpp 和 class1utils.cpp。 clas
我正在尝试将颜色背景更改为默认背景颜色,当我点击输入框外 我尝试使用“null”或“none”但没有用? window.addEventListener('click', outsideClick);
我正在编写一个应用程序,要求用户在手机上选择各种类型的文件。我使用此代码启动文件选择器 Intent : Intent intent = new Intent(Intent.ACTION_GET_C
在 android 中,不可移动(内部)的外部存储和内部存储有什么区别?我不确定在哪里保存我的数据。我只需要保存一个人可以随时提取的游戏统计数据 谢谢 最佳答案 在许多较新的设备中,将不再有物理区别,
在 C++ 中,假设我们有这个头文件: myglobals.h #ifndef my_globals_h #define my_globals_h int monthsInYear = 12; #en
我正在尝试使用 externs 在 C++ 中连接到 Ada。这两种实现有什么区别? 实现A namespace Ada { extern "C" { int getN
这个问题在这里已经有了答案: Get selected element's outer HTML (30 个答案) 关闭 2 年前。 想象一下我们有这样的东西: Hello World 如果我们这样
假设我在模块的顶部有这个: Public Declare Function getCustomerDetails Lib "CustomerFunctions" () As Long 如果我从 VB6
我目前正在使用这段代码: var wordRandomizer = { run: function (targetElem) { var markup = this.creat
我们正在使用 SVN 试水,并以 Beanstalk 作为主机。我们的设置如下所示: 存储库:模块 模块一 模块二 模块 3 存储库:网站1 自定义网站代码 svn:对模块 1 的外部引用 svn:对
有没有办法在负载均衡器中设置自动外部 IP 分配给像谷歌这样的服务? 我在裸机上运行 Kubernetes。 谢谢 最佳答案 使用 nodePort 类型的服务,它会将您的服务绑定(bind)到所有节
是否有可能在 Controller 之外使用 generateUrl() 方法? 我尝试在带有 $this->get('router') 的自定义存储库类中使用它,但它没有用。 更新 我在这里找到了一
我目前正在尝试通过 Webpack 外部对象外部化 Angular 依赖项来缩短构建时间。到目前为止,我已经为 React 和其他小库实现了这一目标。 如果我只是移动 '@angular/compil
我想创建一个自动应用其他插件的插件(外部插件)。这要求在我称为“应用插件”之前为插件设置构建脚本依赖项。但是似乎我无法在插件中添加buildscript依赖项,或者得到了: 您不能更改处于未解析状态的
我是R包的创建者EnvStats . 有一个我经常使用的函数,叫做 stripChart .我刚开始学习ggplot2 ,并在过去几天里仔细研究了 Hadley 的书、Winston 的书、Stack
我是一名优秀的程序员,十分优秀!