我们在多模块项目中使用spring boot.
我们有一个域访问模块,它具有公共域对象类,存储库以及数据源,JPA,Hibernate等的配置.这些是使用application.properties配置的.我们将所有这些配置放入通用模块中,以便在更高级别的模块中保存重复这些常见配置.
这在构建域模块时工作正常,因此配置在测试单元中正确加载.
然而,当我们尝试在更高层模块中使用域模块时,问题就开始了; 他们有自己的application.properties,这意味着Spring加载它们而不是Domain模块application.properties,这意味着没有配置数据源,因为只加载了更高模块的application.properties.
我们想要的是Spring模块和更高级别的应用程序属性.但我们看不到任何简单的方法来做到这一点.
我认为这一定是一个常见的问题,并想知道是否有针对此问题的推荐解决方案?
由于我们使用spring-boot,理想情况下解决方案应该使用注释而不是applictionContext.xml.
我正在寻找等待异步任务在rx-java中完成的最佳方法.
作为一个常见示例,有一个函数从本地存储获取id列表,然后在远程系统中查询这些Id,然后将远程系统结果合并到单个报告中并返回给函数的调用者.由于对远程系统的调用很慢,我们希望它们以异步方式完成,我只想在所有调用都返回并且其结果已经处理后返回.
我发现这样做的唯一可靠方法是轮询订阅以检查它是否已取消订阅.但我认为似乎并不是'RX'做事的方式!
作为一个例子,我从http://howrobotswork.wordpress.com/2013/10/28/using-rxjava-in-android/中取了一个例子并稍微修改它以使它成为非android并显示我的意思.我必须在main()方法的代码中使用以下代码来阻止它立即退出.
while (!subscription.isUnsubscribed()) {
Thread.sleep(100);
}
Run Code Online (Sandbox Code Playgroud)
下面列出了该示例的完整代码(如果您尝试编译它,则依赖于http://square.github.io/retrofit/)
package org.examples;
import retrofit.RestAdapter;
import retrofit.http.GET;
import retrofit.http.Query;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action0;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
public class AsyncExample {
public static void main(String[] args) throws InterruptedException {
final Subscription subscription = Observable.from("London", "Paris", "Berlin")
.flatMap(new Func1<String, Observable<WeatherData>>() {
@Override
public Observable<WeatherData> call(String s) {
return ApiManager.getWeatherData(s);
}
})
.subscribe(
new Action1<WeatherData>() {
@Override
public void call(WeatherData weatherData) {
System.out.println(Thread.currentThread().getName() …Run Code Online (Sandbox Code Playgroud) 我已经采用了Spring SAML示例(请参阅本指南中的第4.2节),该示例与开源登录页面SSO一起使用,并尝试添加支持以将WSO2 Identity Server用作其他IDP服务.为此,我通过为IS添加元数据xml文件来更改spring SAML示例项目,并将一个IS元数据条目添加到securityContext.xml.
在运行spring应用程序时,我现在可以看到使用IS登录的选项,当我被重定向到它时,我可以成功登录WSO2.但是,spring应用程序会在IS SAML响应上抛出异常,因为它与InResponseToField不匹配.
2015-01-05 09:54:12,845 line="org.springframework.security.saml.log.SAMLDefaultLogger.log(SAMLDefaultLogger.java:127)" thread="http-nio-8080-exec-4" class="org.springframework.security.saml.log.SAMLDefaultLogger" AuthNResponse;FAILURE;0:0:0:0:0:0:0:1;com:vdenotaris:spring:sp;localhost;;;org.opensaml.common.SAMLException: InResponseToField of the Response doesn't correspond to sent message ae2dab0fb8b0g8e49971b91a73e91i
Run Code Online (Sandbox Code Playgroud)
从调试应用程序开始,响应消息似乎不被识别为属于与请求消息相同的会话.我说从这两条日志消息中,第一个是在发送AuthRequest时记录的,第二个是在收到响应时:
2015-01-05 09:53:20,867 line="org.springframework.security.saml.storage.HttpSessionStorage.storeMessage(HttpSessionStorage.java:93)" thread="http-nio-8080-exec-1" class="org.springframework.security.saml.storage.HttpSessionStorage" Storing message ae2dab0fb8b0g8e49971b91a73e91i to session 26D3B7D9E33F26A7A5092BF6909B9D13
...
2015-01-05 09:54:10,731 line="org.springframework.security.saml.storage.HttpSessionStorage.retrieveMessage(HttpSessionStorage.java:117)" thread="http-nio-8080-exec-4" class="org.springframework.security.saml.storage.HttpSessionStorage" Message ae2dab0fb8b0g8e49971b91a73e91i not found in session BBF256F284F55D774E6997600E9B3388
Run Code Online (Sandbox Code Playgroud)
IS SAML响应是:
<?xml version="1.0" encoding="UTF-8"?><saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" Destination="http://localhost:8080/saml/SSO" ID="adlbklpnldoanfphalcaahhacooinnldcejjjioe" InResponseTo="ae2dab0fb8b0g8e49971b91a73e91i" IssueInstant="2015-01-05T09:53:38.063Z" Version="2.0">
<saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">localhost</saml2:Issuer>
<saml2p:Status>
<saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</saml2p:Status>
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="ebhfkdhlgbhclcklefjigfddoikklhjlanlbolel" IssueInstant="2015-01-05T09:53:38.065Z" Version="2.0">
<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">localhost</saml2:Issuer>
<saml2:Subject>
<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">smit005</saml2:NameID> …Run Code Online (Sandbox Code Playgroud) 应用程序学问题很长,但总之我想知道如何org.springframework.ldap.core.LdapTemplate#ignorePartialResultException使用Spring Java Config 设置标志。
长期存在的问题是...
我想使用我们公司的Active Directory进行身份验证(这意味着用户/密码检查),然后再进行授权(因此他们有权使用哪些角色)。
我采用了春季ldap指南,并进行了更改以连接到我们公司的Active Directory,而不是使用指南的LDIF文件。通过调试,我知道程序连接到Active Directory并正确验证了用户身份,但是在检索权限时,出现以下异常:
Unprocessed Continuation Reference(s); nested exception is javax.naming.PartialResultException
Run Code Online (Sandbox Code Playgroud)
从谷歌搜索中,我看到这是一个常见的LDAP / ActiveDirectory问题,我需要设置标志以忽略引用。我遵循了这个SO问题中的示例。但是,我仍然遇到异常,通过调试,我可以发现在为用户搜索角色时,以下方法中发生了错误。
org.springframework.ldap.core.LdapTemplate#search(org.springframework.ldap.core.SearchExecutor, org.springframework.ldap.core.NameClassPairCallbackHandler, org.springframework.ldap.core.DirContextProcessor)
Run Code Online (Sandbox Code Playgroud)
作为参考,我的WebSecurityConfig文件:
Unprocessed Continuation Reference(s); nested exception is javax.naming.PartialResultException
Run Code Online (Sandbox Code Playgroud) active-directory spring-ldap spring-security-ldap spring-java-config
当我使用FeignClient它时,它设置Content-Type为application/x-www-form-urlencoded而不是application/json;charset=UTF-8.
如果我使用a RestTemplate发送相同的消息,则消息头Content-Type正确设置为application/json;charset=UTF-8.
无论是FeignClient和RestTemplate正在使用Eureka的服务发现,并通过我调试服务器接收HTTP消息发现了这个问题.
服务器端的控制器如下所示:
@RestController
@RequestMapping("/site/alarm")
public class SiteAlarmController {
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<RaiseAlarmResponseDto> raiseAlarm(@RequestBody RaiseSiteAlarmRequestDto requestDto) {
...
}
Run Code Online (Sandbox Code Playgroud)
我FeignClient在电话报警的服务接口看起来是这样的:
@FeignClient("alarm-service")
public interface AlarmFeignService {
@RequestMapping(method = RequestMethod.POST, value = "/site/alarm")
RaiseAlarmResponseDto raiseAlarm(@RequestBody RaiseSiteAlarmRequestDto requestDto);
}
Run Code Online (Sandbox Code Playgroud)
来自的HTTP消息头FeignClient是:
Accept: */*
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.7.0_60
Host: smit005s-MacBook-Pro.local:9120
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 323 …Run Code Online (Sandbox Code Playgroud) spring-boot ×2
hibernate ×1
java ×1
maven ×1
rx-java ×1
spring ×1
spring-cloud ×1
spring-ldap ×1
spring-saml ×1
wso2 ×1
wso2is ×1