为了安全检查,我需要在我的资源服务中访问用户的远程IP地址.这个资源服务是一个简单的最新Spring Boot应用程序,它使用我的Eureka服务器注册自己:
@SpringBootApplication
@EnableEurekaClient
public class ServletInitializer extends SpringBootServletInitializer {
public static void main(final String[] args) {
SpringApplication.run(ServletInitializer.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
我尤里卡服务器注册的所有服务都通过基于Angel.SR3我Zuul路由代理服务器的动态路由starter-zuul和starter-eureka:
@SpringBootApplication
@EnableZuulProxy
@EnableEurekaClient
public class RoutingProxyServer {
public static void main(final String[] args) {
SpringApplication.run(RoutingProxyServer.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
Zuul路由代理服务器还为下一步配置AJP连接器:
@Configuration
@ConditionalOnProperty("ajp.port")
public class TomcatAjpConfig extends TomcatWebSocketContainerCustomizer {
@Value("${ajp.port}")
private int port;
@Override
public void doCustomize(final TomcatEmbeddedServletContainerFactory tomcat) {
super.doCustomize(tomcat);
// Listen for AJP requests
Connector ajp = new Connector("AJP/1.3");
ajp.setPort(port);
tomcat.addAdditionalTomcatConnectors(ajp);
}
}
Run Code Online (Sandbox Code Playgroud)
对动态路由zuul代理的所有请求都通过Apache代理,以便在标准443端口上提供HTTPS: …
这里有一个相当具体的问题,但它现在
让我烦恼了一天:我在PostgreSQL 8.3上使用Hibernate Core,Annotations&Validator.
我有以下类设置:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Entry {
@EmbeddedId
protected EntryPK entryPK;
@ManyToMany
private Set<Comment> comments = new HashSet<Comment>();
...
@Embeddable
public class EntryPK implements Serializable {
@ManyToOne(cascade = CascadeType.ALL)
private Database database;
@Length(max = 50)
@NotEmpty
private String pdbid;
...
Run Code Online (Sandbox Code Playgroud)
我想看看长度约束在我的PostgreSQL数据库中转换为长度约束(它适用于@ Entity中的其他字段,而不是@ Embeddable's),但它似乎并不想工作..
甚至使用@IdClass代替@EmbeddedId并在@Entity中的匹配字段上应用Length约束并没有解决这个问题:数据库字段仍然是varchar 255(大约250太大了,不能满足我的需要).
有些人可能会说我不应该关心这个详细程度,但我的OCD方面拒绝放手......;)是不是可以在EmbeddedId中使用Hibernate Validator Annotations并让hbm2ddl将约束应用于数据库字段?
在浏览我碰上了这个博客帖子大约使用维基百科的API从JavaScript的,连结一个搜索词给它的定义.在博客文章的最后,作者提到了可能的扩展,包括:
一个插件,自动将术语链接到维基百科文章.
这完全符合我正在处理的项目要求,但遗憾的是我缺乏扩展原始源代码的编程技巧.我想要的是拥有一个我可以添加到网页的纯JavaScript代码段,它将该网页上包含内部维基文章的所有条款链接到该Wiki.
我知道这可能要求很多,但代码看起来几乎就在那里,如果有人为这个虚拟信用做剩下的工作,我愿意加一个赏金..;)我也怀疑这可能是对其他几个人有价值,因为我看过类似的请求,但没有工作实现(这只是一个JavaScript(因此是可移植的)库/代码段包括).
这是原始源代码的示例,我希望有人能够添加到此或指向我需要添加的内容,如果我自己实现这一点(在这种情况下,如果我设法我将共享代码把东西放在一起).
<script type="text/javascript"><!--
var spellcheck = function (data) {
var found = false; var url=''; var text = data [0];
if (text != document.getElementById ('spellcheckinput').value)
return;
for (i=0; i<data [1].length; i++) {
if (text.toLowerCase () == data [1] [i].toLowerCase ()) {
found = true;
url ='http://en.wikipedia.org/wiki/' + text;
document.getElementById ('spellcheckresult').innerHTML = '<b style="color:green">Correct</b> - <a target="_top" href="' + url + '">link</a>';
}
}
if (! found)
document.getElementById ('spellcheckresult').innerHTML …Run Code Online (Sandbox Code Playgroud) 我发现了这个:https://github.com/ether/etherpad-lite/wiki/How-to-list-all-pads
但我真的无法想象如何使用它.我是否必须修改我的templates/index.html并添加该段代码?哪里?谢谢!
我已经完成了几个教程的混搭,也没有太成功!
我试图让Apache CXF和WS-Security回调我的Spring Security身份验证器.一切都接近工作但是在某个时刻,我在获取密码以使Spring安全性退出WS-call时遇到问题.
下面的处理程序变得很难,但pc.getPassword()为空.我希望这是在Soap中发送的密码,所以我可以把它传递给spring
public class ServerPasswordCallback implements CallbackHandler {
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
pc.setPassword( pc.getPassword() );
}
Run Code Online (Sandbox Code Playgroud)
我的拦截器设置如此
<bean id="wsAuthenticationInterceptor" class="com.olympus.viewtheworld.server.security.auth.WSAuthenticationInInterceptor">
<constructor-arg index="0">
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
<entry key="passwordCallbackClass" value="com.olympus.viewtheworld.server.security.auth.ServerPasswordCallback" />
</map>
</constructor-arg>
<property name="authenticationManager" ref="authenticationManager"/>
</bean>
<jaxws:endpoint id="secureHelloService"
implementor="#secureHelloServiceImpl"
implementorClass="com.olympus.viewtheworld.server.service.Impl.SecureHelloServiceImpl"
address="/SoapService/secure/hello">
<jaxws:serviceFactory>
<ref bean="jaxws-and-aegis-service-factory" />
</jaxws:serviceFactory>
<jaxws:inInterceptors>
<bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
<ref bean="wsAuthenticationInterceptor" />
</jaxws:inInterceptors>
</jaxws:endpoint>
Run Code Online (Sandbox Code Playgroud)
我从SoapUI发出的soap请求是
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> …Run Code Online (Sandbox Code Playgroud) 我的应用程序需要在Postgres,Mysql和测试Hsqldb之间移植.我已经设置了Flyway来为这三个提供一些自定义函数,我现在想在我的SQL/HQL查询中使用它们.
我目前的设置是使用Dialect我在之间切换的单独的s application-{profile}.yml; 哪个有效,但函数声明需要在各种方言之间重复,并且感觉不是最理想的.
看着15.29.Hibernate文档中的非标准化函数,它说我应该使用org.hibernate.cfg.Configuration#addSqlFunction(),它似乎更便携,并且无需扩展所有三种方言.
我的问题是:如何Configuration在Spring Boot(1.3)应用程序中访问Hibernate 类?默认情况下没有bean可以注入,也没有LocalSessionFactoryBeanbean.
任何人都可以指出我正确的方向,或以其他方式注册我的SQL函数一次?
我最近有一个问题,我的java代码在我的本地机器上工作得很好,但是当我将它部署到Web服务器上时,它就不起作用了,尤其是数据库部分.最糟糕的是服务器不是我的机器.所以我不得不来回检查软件版本,数据库帐户,设置等等......
我不得不承认我在系统中没有做好日志记录机制.然而,作为一个经验不足的新手程序员,我不得不接受我的学习曲线.因此,这是一个非常普遍但重要的问题:
根据您的经验,当它在开发机器上完美运行时,它最可能出错的地方,但在生产机器上完全让您感到惊讶?
感谢您分享您的经验.
我在防止Spring Boot自动配置某些类(在此示例中为SolrAutoConfiguration)方面遇到了一些困难.为了说明我设置了一个简化的例子:
https://github.com/timtebeek/componentscan-exclusions
实际上,有大约20多个内部@SpringBootApplication项目,每个项目都有自己的依赖项.(不理想/不是我的想法,但现在很难离开.)
问题出现是因为多个子项目正在使用Solr 5.2.1,但Spring Boot仅与4.x兼容.在最终的应用程序中(示例中的module-b)我想@SpringBootApplication在所有模块中导入所有类,同时阻止SolrAutoConfiguration运行:
@ComponentScan("project") // Broad scan across all company jars
@SpringBootApplication(exclude = { SolrAutoConfiguration.class }) // Failing exclude
public class ModuleBApp {
public static void main(final String[] args) {
SpringApplication.run(ModuleBApp.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
这失败了,因为@SpringBootApplication通过@ComponentScan没有特定排除的任何实例仍然加载SolrAutoConfiguration.
在组合多个@SpringBootApplication类时,如何正确排除自动配置类?
我已经尝试过excludeFilters我的决赛@SpringBootApplication,但这还没有找到解决方案.
我正在对由 zuul 代理服务支持的简单 spring 云应用程序进行一些压力测试,由于 Zuul 和服务之间的连接陈旧,我们偶尔会遇到管道异常异常。我用不同的配置选项配置了 Zuul,但没有成功:
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 61000
ribbon:
ReadTimeout: 60000
ConnectTimeout: 6000
zuul:
host:
socket-timeout-millis: 60000
connect-timeout-millis: 60000
Run Code Online (Sandbox Code Playgroud)
提前感谢您提供解决此问题的任何线索。例外如下:`
com.netflix.zuul.exception.ZuulException:org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:151) ~[router.jar!/:0.0.1] 处的转发错误org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:114) ~[router.jar!/:0.0.1] at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java :112) ~[zuul-core-1.0.28.jar!/:na]
引起:com.netflix.hystrix.exception.HystrixRuntimeException:query-serviceRibbonCommand 失败且没有可用的回退。在 com.netflix.hystrix.AbstractCommand$20.call(AbstractCommand.java:816) ~[hystrix-core-1.4.0-RC6.jar!/:na] 在 com.netflix.hystrix.AbstractCommand$20.call(AbstractCommand. java:798) ~[hystrix-core-1.4.0-RC6.jar!/:na] at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:77) ~[rxjava-1.0.4.jar! /:1.0.4] 在 rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.4.jar!/:1.0.4]
引起:java.net.SocketException: 在 java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_45] 在 java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109) ~[na: 1.8.0_45] 在 java.net.SocketOutputStream.write(SocketOutputStream.java:153) ~[na:1.8.0_45] 在 org.apache.http.impl.io.AbstractSessionOutputBuffer.flushBuffer(AbstractSessionOutputBuffer.java:159) ~[ httpcore-4.3.3.jar!/:4.3.3] ... 在 rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55) ~[rxjava-1.0.4.jar!/:1.0.4 ] 在 com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:185) ~[ribbon-loadbalancer-2.0-RC13.jar!/:na] 在 com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call (LoadBalancerCommand.java:180
这段代码我需要一些帮助.我知道应该递归的部分,或者至少我认为我这样做但不确定如何实现它.我正在尝试从对齐矩阵实现路径查找程序,该矩阵将找到多个路由回零值.例如,如果您执行我的代码并插入CGCA作为第一个序列,并将CACGTAT作为第二个序列插入,并将1,0和-1作为匹配,不匹配和差距分数.该程序给出了HDHHDD和对象的路径
CACGTAT
CGC - A-.
然而,除此之外,还有更多可能的路径和对象,除了我不知道有多少.我想要做的是让我的代码循环回到自身并找到其他路径和对齐,使用与第一次相同的代码,直到它用完可能的对齐.我在网上找到的最好的方法是递归,除了没有人能解释如何做到这一点.在这种情况下,应该有两个以上的路径和对话框HDDDHHD和CACGTAT,以及C - GCA-和.HDDDDHH,CACGTAT和--CGCA-.我只是不知道如何编写代码来执行此任务.
# Implementation of Needleman and Wunsch Algorithm
my($seq1, $len1, $seq2, $len2, $data, @matrix, $i, $j, $x, $y, $val1, $val2);
my($val3, $pathrow, $pathcol, $seq1loc, $seq2loc, $gapscore, $matchscore, $mismatchscore);
#first obtain the data from the user.
print "Please enter the first sequence for comaprsion\n";
$seq1=<STDIN>;
chomp $seq1;
print "Please enter the second sequence for comparsion\n";
$seq2=<STDIN>;
chomp $seq2;
# adding extra characters so sequences align with matrix
# saves some calculations later on
$seq1 …Run Code Online (Sandbox Code Playgroud) 我正在使用动态数据源路由,如本博客文章中所示:http: //spring.io/blog/2007/01/23/dynamic-datasource-routing/
这很好,但是当我将它与spring-data-rest浏览我生成的存储库结合起来时,我(正确地)得到了一个异常,我的查找键没有被定义(我没有设置默认值).
在与数据库建立任何连接之前,如何以及在何处可以挂钩Spring数据休息请求处理以基于"x"(用户授权,路径前缀或其他)设置查找键?
代码方面我的数据源配置主要与顶部的blogpost匹配,包括一些基本的实体类,生成的存储库和Spring Boot以将所有内容包装在一起.如果需要我可以发布一些代码,但没有什么可看的.
java ×4
hibernate ×2
netflix-zuul ×2
spring-boot ×2
spring-cloud ×2
algorithm ×1
alignment ×1
apache ×1
cxf ×1
deployment ×1
dna-sequence ×1
etherpad ×1
hbm2ddl ×1
indexing ×1
javascript ×1
logging ×1
perl ×1
solr ×1
spring-data ×1
sql-function ×1
validation ×1
wikipedia ×1
ws-security ×1