redshift database 连接异常

解决方案

url 修改添加参数如下

jdbc:redshift://hostname:5439/dbname?ssl=true&sslfactory=com.amazon.redshift.ssl.NonValidatingFactory

java 8 lambda 表达式应用

// 拆分 参数并去左右空格
public static List<String> splitStr2List(String params,String delimeter){
return Arrays.asList(params.split(delimeter)).stream().map(param->param.trim()).collect(Collectors.toList());
}

spring 中一个接口多个实现类注入

1. 首先, Interface1 接口有两个实现类 Interface1Impl1 和 Interface1Impl2

Interface1 接口:

package com.example.service;

/**
* Created by liuzh on 2018-05-29.
* 接口1
*/
public interface Interface1 {
void fun1();
}
以下是接口的两个实现类,请注意@service注解的使用方式,这里给每个实现类标注了不同的名称,方便在@Resource注入时区别注入 Interface1 接口实现类1: package com.example.service.impl; import com.example.service.Interface1;
import org.springframework.stereotype.Service; /**
* Created by liuzh on 2018-05-29.
*/
@Service("s1")
public class Interface1Impl1 implements Interface1 {
@Override
public void fun1() {
System.out.println("接口1实现类 ...");
} public void fun2(){
System.out.println("接口1实现类1 fun2 ...");
}
}
20
Interface1 接口实现类2: package com.example.service.impl; import com.example.service.Interface1;
import org.springframework.stereotype.Service; /**
* Created by liuzh on 2018-05-29.
*/
@Service("s2")
public class Interface1Impl2 implements Interface1 {
@Override
public void fun1() {
System.out.println("接口1实现类 ...");
} public void fun2(){
System.out.println("接口1实现类2 fun2 ...");
}
}
2. 通过 @Autowired 和 @Qualifier 配合注入 @Autowired
@Qualifier("interface1Impl1")
Interface1 interface1; //正常启动 3. 使用@Resource注入,根据默认类名区分 @Resource(name = "interface1Impl1")
Interface1 interface1; //正常启动 4. 使用@Resource注入,根据@Service指定的名称区分 @Resource(name = "s1")
Interface1 interface1; //正常启动
使用@Resource注入,根据@Service指定的名称区分,可以避免多个实现类在不同包下,但是类名相同的情况。

最近项目需要添加 SSO ,webservice 也难逃一劫,所以这里用上 拦截器做 SSO 拦截

package com.middleplugin.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class SSOInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
return false;
} @Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { } @Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { }
} package com.middleplugin.interceptor; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @EnableWebMvc
@Configuration
public class AdapterConfig extends WebMvcConfigurerAdapter {
@Bean
SSOInterceptor ssoInterceptor(){
return new SSOInterceptor();
} public void addInterceptors(InterceptorRegistry registry){
// 多个拦截器组成一个拦截器链
// addPathPatterns 用于添加拦截规则
// excludePathPatterns 用户排除拦截
registry.addInterceptor( ssoInterceptor()).addPathPatterns("/**");
super.addInterceptors(registry);
}
}

构造访问请求命令, 便于 工作

    for query_string in ['colon cancer, NTRK1, NTRK2, NTRK3',
'colon cancer NTRK1 NTRK2 NTRK3',
'breast cancer patients who are at least 18 years old',
'breast cancer 18 years or older','breast cancer patients age 70 to 80',
'pancreatic cancer patients age 80 or older',
'patients with breast cancer, gene mutation NTRK1, NTRK2, NTRK3, and do not have larotrectinib',
'patients with breast cancer, gene mutation NTRK1, NTRK2, NTRK3, and no larotrectinib',
'colon cancer patient with overall survival over 18 months','colon cancer patient with overall survival more than 18 months',
'colon cancer patient with karnofsy > 60%','colon cancer patient with karnofsy greater than 60%']:
template = """ curl -v -H 'Content-Type: application/json' -X POST -d '$"query_string":"{}"@' http://localhost:5000/v1/nlpquery/get """.format(query_string)
template = template.replace(r'$','{').replace(r'@','}')
print(template)

webservice 项目中遇到的问题的更多相关文章

  1. 在web项目中使用cxf开发webservice,包含spring支持

    本文主要介绍了,如何使用cxf内置的例子,学会开发webserivce,在web项目中使用,且包含spring支持. webserivce的开发可以使用cxf或者axis,好像还有httpclient ...

  2. 在java项目中使用webservice

    今天学习webservice,主要参考了网络上的一些文章. 1.关于原理的介绍:个人认为这篇文章写得不错了,戳这里. 2.关于demo的编写:个人认为这篇文章很简洁,也能运行成功,戳这里. 按照上面那 ...

  3. java web项目(spring项目)中集成webservice ,实现对外开放接口

    什么是WebService?webService小示例 点此了解 下面进入正题: Javaweb项目(spring项目)中集成webservice ,实现对外开放接口步骤: 准备: 采用与spring ...

  4. JAVA项目中公布WebService服务——简单实例

    1.在Java项目中公布一个WebService服务: 怎样公布? --JDK1.6中JAX-WS规范定义了怎样公布一个WebService服务. (1)用jdk1.6.0_21以后的版本号公布. ( ...

  5. 如何在SpringMVC项目中部署WebService服务并打包生成客户端

    场景 某SpringMVC项目原本为一个HTTP的WEB服务项目,之后想在该项目中添加WebService支持,使该项目同时提供HTTP服务和WebService服务.其中WebService服务通过 ...

  6. myeclipse构建webservice项目

    新建server端 1 创建Web Service Project项目 2.项目名称:HelloWorldServer 3.创建接口类 4.发布 选择项目名称,选择从Java类中构建web servi ...

  7. 转 web项目中的web.xml元素解析

    转 web项目中的web.xml元素解析 发表于1年前(2014-11-26 15:45)   阅读(497) | 评论(0) 16人收藏此文章, 我要收藏 赞0 上海源创会5月15日与你相约[玫瑰里 ...

  8. Axis2在Web项目中整合Spring

    一.说明: 上一篇说了Axis2与Web项目的整合(详情 :Axis2与Web项目整合)过程,如果说在Web项目中使用了Spring框架,那么又改如何进行Axis2相关的配置操作呢? 二.Axis2 ...

  9. 如何查看.Net源代码vs版本号以及C#项目中各文件的含义

    查看.Net源代码vs版本号以及C#项目中各文件的含义 用记事本打开vs项目的.sln文件. 第2行就是这个源代码包的开发软件vs版本号了 注意了,如果是vs2003的sln文件通常没有这行,可以判断 ...

随机推荐

  1. 【BZOJ2823】[AHOI2012]信号塔(最小圆覆盖)

    [BZOJ2823][AHOI2012]信号塔(最小圆覆盖) 题面 BZOJ 洛谷 相同的题: BZOJ1 BZOJ2 洛谷 题解 模板题... #include<iostream> #i ...

  2. push的时候报错:Permission denied (publickey)

    最近,在push的时候遇到一个问题,简单描述下过程(git客户端命令行操作) 我先在本地建了一个文件夹,mkdir dubbodemo 然后进入到这个文件夹,cd dubbodemo 添加我的内容 初 ...

  3. 【Linux】linux中文本操作利器grep,awk,sed

    grep命令 grep(global search regular expression)是一种强大的文本搜索工具,它可以使用正则表达式搜索文本,并把匹配的行打印出来.平时搜索文本中内容的时候是非常方 ...

  4. iptables防火墙详解(二)

    -- 基于状态的iptables 如果按照tcp/ip来划分连接状态,有11种之多(课后可以自己去读一下相关知识) 但iptables里只有4种状态:ESTABLISHED.NEW.RELATED及I ...

  5. Git设置彩色输出

    彩色输出 git config --global color.status auto git config --global color.diff auto git config --global c ...

  6. Django(十)COOKIE和session

    https://www.cnblogs.com/haiyan123/p/7763169.html from django.shortcuts import render,redirect # Crea ...

  7. react-native中使用长列表

    React Native 提供了几个适用于展示长列表数据的组件,一般而言我们会选用FlatList或是SectionList. FlatList组件用于显示一个垂直的滚动列表,其中的元素之间结构近似而 ...

  8. Nginx.conf配置文件参数说明与优化

    参考连接:nginx 核心配置优化详解 先说下优化 1.nginx运行工作进程个数 worker_processes  1; Nginx进程,一般设置为和cpu核数一样(nginx启动后有多少个wor ...

  9. 第二十九节,目标检测算法之R-CNN算法详解

    Girshick, Ross, et al. “Rich feature hierarchies for accurate object detection and semantic segmenta ...

  10. 0基础如何学Android开发

    链接:http://pan.baidu.com/s/1bIEIse 密码:ky7w https://pan.baidu.com/s/1i53bs6x提取码:0pwthttps://www.zhihu. ...