2
我有以下类:泽西2化妆类/对象持续整个应用程序
package com.crawler.c_api.rest;
import com.crawler.c_api.provider.ResponseCorsFilter;
import java.util.logging.Logger;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
public class ApplicationResource extends ResourceConfig {
private static final Logger LOGGER = null;
public ServiceXYZ pipeline;
public ApplicationResource() {
System.out.println("iansdiansdasdasds");
// Register resources and providers using package-scanning.
packages("com.crawler.c_api");
// Register my custom provider - not needed if it's in my.package.
register(ResponseCorsFilter.class);
pipeline=new ServiceXYZ();
//Register stanford
/*Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
pipeline = new StanfordCoreNLP(props);*/
// Register an instance of LoggingFilter.
register(new LoggingFilter(LOGGER, true));
// Enable Tracing support.
property(ServerProperties.TRACING, "ALL");
}
}
我想使可变管道持续整个应用程序,所以我可以一次初始化服务,并在所有其他使用它类。
我该怎么做?
再次感谢:)似乎更复杂,然后我想。稍后会看看! –
其实并没有那么复杂。您可以复制并粘贴第一个代码片段,然后只需将注释添加到您需要的地方 –
好极了!有用。没有不复杂;) –