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");
}
}
我想使可變管道持續整個應用程序,所以我可以一次初始化服務,並在所有其他使用它類。
我該怎麼做?
再次感謝:)似乎更復雜,然後我想。稍後會看看! –
其實並沒有那麼複雜。您可以複製並粘貼第一個代碼片段,然後只需將註釋添加到您需要的地方 –
好極了!有用。沒有不復雜;) –