我正在构建可能每秒可能有大量请求的API,而某些请求可能需要大量计算(复杂报告).我被要求组装一个小型原型作为概念证明.我使用带有Jersey的Spring Boot作为我的JAX-RS实现.在过去,我用Spring MVC做过类似的事情.
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
public DeferredResult<String> showDashboard(Model model) {
DeferredResult<String> result = new DeferredResult<>();
model.addAttribute("testObj", new User());
result.setResult("home/dashboard");
return result;
}
Run Code Online (Sandbox Code Playgroud)
我在泽西岛试过这个并且看起来很有用,或者至少它没有出错.
@GET
public DeferredResult<String> getClients() {
DeferredResult<String> deferredResult = new DeferredResult<>();
deferredResult.setResult("Nothing! But I'm Async!");
return deferredResult;
}
Run Code Online (Sandbox Code Playgroud)
但是,我在Jersey中异步处理操作的所有示例都是这样的.
Produces(MediaType.TEXT_PLAIN)
public void get(@Suspended final AsyncResponse response) {
// This call does not block.
client.callExternalService(
// This callback is invoked after the external service responds.
new Callback<string>() {
public void callback(String result) {
response.resume("Result: " …Run Code Online (Sandbox Code Playgroud) 我一直在关注Java 8的供应商和消费者接口以及我所理解的它可以取代构造函数调用.
我在dzone(链接在这里)上看到了一个使用ShapeFactory的例子.代码非常简单,是一个简单的形状类工厂.
但她如此使用它:
Supplier<ShapeFactory> supplier = ShapeFactory::new;
supplier.get().getShape("rectangle").draw();
Run Code Online (Sandbox Code Playgroud)
但为什么它比做一个简单的经典更好:
ShapeFactory factory = new ShapeFactory();
factory.getShape("rectangle").draw()
Run Code Online (Sandbox Code Playgroud)
这足够简单和有效.此外,如果ShapeFactory类的构造函数具有参数,则Supplier将无法工作,我们将不得不使用Function或其他方法.
那么为什么在这个精确的情况下使用像这样的供应商?
我的spring + maven项目有.properties和.xml资源文件.我想为.properties设置过滤,只排除所有spring xml配置.这是非常简单的事情:
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
Run Code Online (Sandbox Code Playgroud)
但现在我想将过滤器应用于一个具体的xml文件,比如env-config.xml.所以问题是如何将过滤器应用于所有.properties文件和仅一个特定的xml文件?
我想使用Android DrawerLayout和NavigationView菜单,但我不知道如何让菜单项使用自定义字体.有没有人成功实施?
android android-fonts android-menu android-typeface android-drawer
我正在使用Keycloak版本1.6.1,作为独立应用程序新安装.
Keycloak应该充当名为Tableau的SP(服务提供商)的IdP(身份提供商).
我已阅读此页面:http://blog.keycloak.org/2015/03/picketlink-and-keycloak-projects-are.html
......来自Identity Broker的Keycloak发展成为完全成熟的身份提供商
虽然它是Identity Broker,但它现在也是一个身份提供商.
我的问题是:
我已经从Tableau导出了SP XML元数据,我将其导入Keycloak,但是当从Keycloak导出IdP XML元数据(应该导入到Tableau中)时,我无法找到关于如何导入的按钮/命令/指南导出此XML文件.
我与其他IdP合作过,他们都支持IdP元数据的导出,您可以在此处看到一个示例:https://docs.oracle.com/cd/E19636-01/819-7664/g2enua/index.html
如果我搜索Keycloak和关键字IDPSSODescriptor,我会发现: grepcode.com/file/repo1.maven.org/maven2/org.keycloak/keycloak-saml-protocol/1.1.0.Beta2/idp-metadata-template.xml
这正是我需要的'模板',所有$ {idp.sso.HTTP-POST}等地方都有正确的链接.
我应该手动创建文件 - 如果是这样,我如何找到正确的POST,REDIRECT等URL?
或者是否有某种导出此文件的方法我还没见过?
我在Alexa开发人员控制台中看到一种奇怪的行为,其中一种技能具有配置的端点值:
使用端点的一些旧的现金值(请注意与配置中的上述值的URL差异:https : //87d44b5e.ngrok.io/kai/api/v1/alexa),导致SKILL_ENDPOINT_ERROR:
可以在Alexa外部完全访问已配置的端点(https://87d44b5e.ngrok.io/kai/api/v1/alexa)。
设备日志的异常堆栈中引用的端点值是不同的:https : //simeonleyzerzon5.localhost.run/kai/api/v1/alexa。我不知道它的起源,但这是我几天前一直在使用的旧式端点。由于这些值一天要过期几次,因此需要在Alexa开发人员控制台中对其进行重新配置。似乎它已被Alexa内部缓存。
该技能已启用帐户关联。
我尝试清理浏览器cookie,重新启动浏览器,以隐身模式运行,在Alexa json编辑器中重新保存和重建模型,在其中重新保存端点的正确值,在开发人员控制台上禁用帐户链接,禁用并通过https://alexa.amazon.com重新启用该技能-似乎无济于事。在不同的浏览器中,同样的错误也仍然存在。
通过开发人员控制台的|邀请我与同事分享了一项技能 设置| 用户权限,他能够毫无错误地运行该技能,并且不会遇到错误的缓存行为(他的技能使用了新近更新的端点),而对我而言,这种情况还在继续发生。
似乎Alexa会在每个用户存储某个点的某个技能时的快照,这时会存储端点值(也许还有其他值?),然后将其重用,有人可以解释一下该存储发生的时间以及如何重置该记忆吗?
以上是正确的假设吗?如果是,那么是否进行了记忆以防止在将技能分发给(通过链接)并被多个用户击中时发生并发相关问题的风险?还是打算用于其他用途?
如何解决这一错误行为?
用户和技能之间的关系是什么?为什么几个用户共享的技能状态不一致?如何在使用该技能的所有用户中触发该技能状态的重置和重新同步。是什么使它不同步?
我正在尝试将我的xml servlet配置迁移到java配置.
以下配置是我的servlet配置,它在Controller层上启用自定义安全注释.
<security:global-method-security pre-post-annotations="enabled">
<security:expression-handler ref="expressionHandler"/>
</security:global-method-security>
<bean id="expressionHandler" class="yyy.MyMethodSecurityExpressionHandler" />
Run Code Online (Sandbox Code Playgroud)
我还有一个工作的spring security xml配置,这是为了被java配置替换,但现在不是.这里有一些我的安全配置:
<bean id="authenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService" />
</bean>
<bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
<constructor-arg>
<ref bean="authenticationProvider"/>
</constructor-arg>
</bean>
<security:authentication-manager>
<security:authentication-provider user-service-ref="userDetailsService" />
</security:authentication-manager>
<security:global-method-security pre-post-annotations="enabled" />
Run Code Online (Sandbox Code Playgroud)
我想开始迁移我的servlet配置@PreAuthorize,@PostAuthorize在Controller层中启用安全性和标记.
我发现了这个注释:@EnableGlobalMethodSecurity(prePostEnabled=true)但是把它放在我的servlet配置上:
@Configuration
@ComponentScan(basePackages= {
"....."
})
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class WebappServletConfig extends WebMvcConfigurationSupport {
Run Code Online (Sandbox Code Playgroud)
我得到这个例外:
java.lang.IllegalArgumentException: Expecting to only find a single bean for type interface org.springframework.security.authentication.AuthenticationManager, but found []
Run Code Online (Sandbox Code Playgroud)
而且我不知道如何设置我的自定义表达式处理程序!
有人提示吗?谢谢
以下设置似乎不生成.pid文件(如此处所述 - http://www.kubrynski.com/2014/05/managing-spring-boot-application.html:
public static void main(String[] args) {
SpringApplication app = new SpringApplication(BrokerFeedApplication.class);
app.addListeners(new ApplicationPidFileWriter());
app.run(BrokerFeedApplication.class, args);
}
Run Code Online (Sandbox Code Playgroud)
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
自从Apache发布了Johnzon的第一个最终版本以来,看看Johnzon和FastXML Jackson之间是否已经有一些比较,看看是否值得进行转换,将是非常有趣的。最重要的主题可能是性能。
有没有人做过性能测试?您可以分享您的结果吗?
最好
KafkaPropertiesjava 文档:
/**
* What to do when there is no initial offset in Kafka or if the current offset
* does not exist any more on the server.
*/
private String autoOffsetReset;
Run Code Online (Sandbox Code Playgroud)
我有你好世界应用程序,其中包含application.properties
spring.kafka.consumer.group-id=foo
spring.kafka.consumer.auto-offset-reset=latest
Run Code Online (Sandbox Code Playgroud)
在这种情况下,@KafkaListener将为所有条目调用方法。但预期结果是@KafkaListener仅针对我发送的最新 3 个选项调用该方法。我尝试使用另一个选项:
spring.kafka.consumer.auto-offset-reset=earlisest
Run Code Online (Sandbox Code Playgroud)
但行为是一样的。
你能解释一下这个东西吗?
代码示例:
@SpringBootApplication
public class Application implements CommandLineRunner {
public static Logger logger = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication.run(Application.class, args).close();
}
@Autowired
private KafkaTemplate<String, String> template;
private final CountDownLatch …Run Code Online (Sandbox Code Playgroud) spring ×4
java ×3
spring-boot ×2
alexa ×1
alexa-skill ×1
android ×1
android-menu ×1
apache ×1
apache-kafka ×1
asynchronous ×1
filtering ×1
jackson ×1
jersey ×1
json ×1
keycloak ×1
maven ×1
objectmapper ×1
resources ×1
saml-2.0 ×1
spring-kafka ×1
spring-mvc ×1
ssh ×1
tableau-api ×1