package com.easymylife.app.sys;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.spring.scope.RequestContextFilter;
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(RequestContextFilter.class);
packages("com.easymylife.app.sys");
//register(LoggingFeature.class);
}
}
添加 SpringAnnotationConfig 类
package com.easymylife.app.sys;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* Spring configuration to include our services
*
*/
@Configuration
@ComponentScan(basePackageClasses = {})
public class SpringAnnotationConfig {
}
然后在 main 中调用
final JerseyConfig resourceConfig = new JerseyConfig();
resourceConfig.property("contextConfig", new AnnotationConfigApplicationContext(SpringAnnotationConfig.class));
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), resourceConfig, false);
就可以通过 @Autowired 注解进行注入
@Singleton
@Path("spring-resource")
@Service
public class SpringRequestResource {
AtomicInteger counter = new AtomicInteger();
/* @Autowired
private GoodbyeService myGoodbyeService;*/
@Autowired
private ISaySthService saySthService;
@GET
@Path("saysth")
@Produces(MediaType.TEXT_PLAIN)
public String getSaySth(){
return this.saySthService.hello("Grissom");
}
@GET
@Path("users")
@Produces(MediaType.APPLICATION_JSON)
public List getUsers(){
return this.saySthService.getUsers();
}
}
网上关于SQL优化的教程很多,但是比较杂乱。近日有空整理了一下,写出来跟大家分享一下,其中有错误和不足的地方,还请大家纠正补充。
这篇文章我花费了大量的时间查找资料、修改、排版,希望大家阅读之后,感觉好的话推荐给更多的人,让更多的人看到、纠正以及补充。
1.对查询进行优化,要尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。
2.应尽量避免在 where
Zookeeper类是Zookeeper提供给用户访问Zookeeper service的主要API,它包含了如下几个内部类
首先分析它的内部类,从WatchRegistration开始,为指定的znode path注册一个Watcher,
/**
* Register a watcher for a particular p
何为部分应用函数?
Partially applied function: A function that’s used in an expression and that misses some of its arguments.For instance, if function f has type Int => Int => Int, then f and f(1) are p