【Java – Spring Web-Flux中的Backpressure机制】教程文章相关的互联网学习教程文章

java – spring boot是否提供标准的登录和注册支持【代码】

我找到了一些关于Spring Security登录和注册的教程: http://www.baeldung.com/spring-security-login-error-handling-localization http://www.baeldung.com/registration-with-spring-mvc-and-spring-security 但是,我现在正在使用Spring Boot,并希望找到该教程.问题是,我能找到的只是OAuth2和SSO http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/(第28点) 如果我想用Spring Boot实现一个简单的登...

java – Spring Cloud Config Encryption API最后会忽略特殊字符【代码】

我们使用Spring云配置外部化了我们的应用程序配置.我们还使用Encryption API在明文密码进入yaml属性文件之前对其进行加密. 我正在努力加密下游系统的密码,最后有特殊的性能.不知怎的,云配置加密API已经忽略了它.当您使用解密API解密密码时,您将获得纯文本,而最后没有特殊字符. 我使用curl来调用API – curl 10.102.82.1:11901/encrypt -d AXIzFDH4XZA= 由于某种原因,纯文本中间的特殊字符工作正常,但如果你在最后有它,那么它被忽...

java – Spring JPA:如何在不丢失数据的情况下进行upsert【代码】

如果不存在,是否有任何方法可以插入新记录并在不丢失旧数据的情况下更新记录? 这是我的服务层方法:public void saveSample(Sample sample) {Sample samplePersistent = sample;if (sample.getId() != null) {samplePersistent = sampleRepository.findOne(sample.getId());Assert.notNull(samplePersistent, "Sample entity not found with id : " + sample.getId());samplePersistent.setLocation(sample.getLocation());sample...

java – 为什么spring boot总是在两个小时内关闭【代码】

我使用mvn clean包构建它并获取一个xxx.jar文件. 运行$java -jar xxx.jar>> output.log&启动它,它运作良好. 但大约两个小时后,它关机,为什么?这是一个答案,但不适合我>> https://stackoverflow.com/a/22409655/1767024 这是我的output.log:. ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )' |____| .__|_| ...

java – Spring @Autowired bean没有初始化;空指针异常【代码】

Target.java:package me;@Component public class Target implements Runnable { @Autowiredprivate Properties properties;public Target(){properties.getProperty('my.property');}public void run() {//do stuff} }Config.java:@Configuration @ComponentScan(basePackages = {"me"}) public class Config {@Bean(name="properties")public PropertiesFactoryBean properties() {PropertiesFactoryBean bean = new Propert...

java – 在spring控制器中获取_csrf【代码】

如何在弹簧控制器中获取_csrf对象(?!)?我已经配置了Spring Security并且可以在jsp文件中获得${_ csrf}请求属性.我试过了:CsrfToken _csrf = (CsrfToken) session.getAttribute("CsrfToken"); CsrfToken _csrf = (CsrfToken) session.getAttribute("_csrf");结果为null; 提前致谢!解决方法:在调试中,我看到了一个带有键“org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository.CSRF_TOKEN”的会话属性.我查看...

java – Spring Security BadCredentialsException如何映射到HTTP 401代码【代码】

当我抛出一个org.springframework.security.authentication.BadCredentialsException异常时,在客户端它将显示如下401,{"timestamp": "2016-03-29T09:07:50.866+0000","status": 401,"error": "Unauthorized","message": "Some message","path": "/test/service1/getAll" }我想知道BadCredentialsException在哪里以及如何映射到HTTP 401状态代码?解决方法:它是ExceptionTranslationFilter,它处理安全拦截器抛出的异常,并提供合适的...

java – Spring bean destroy方法【代码】

什么可能是在现实世界的应用程序中使用destroy方法的示例?为什么正在运行的应用程序想要销毁它的bean?如果bean是由用于Web应用程序的spring容器创建的,例如ContextLoaderListener,那么如何重新创建这些bean,因为容器已经启动.有没有办法重新启动弹簧IoC容器而无需重新启动应用程序服务器?解决方法:一个例子是DataSource或需要清理的任何资源.你可能会有这样的事情:@Bean(destroyMethod = "close") DataSource dataSource() {.....

java – 与Spring异步执行的并行【代码】

我想迭代一个元素列表并异步地(以并行方式)对它们执行操作. 这是我的代码:@Autowired ElemManager elemManager;... List<Elem> elems = new ArrayList<>();for ( Elem elem : elems ) {System.out.println(elemManager.doSomething(elem).get()); }其中ElemManager是:public class ElemManager {@Asyncpublic Future<String> doSomething( Elem elem ) {// do somethingreturn "done"; }我还在spring上下文中创建了一个线程池并...

java – Spring websocket STOMP取消订阅eventHandler【代码】

我有一个Spring Websocket Stomp应用程序,它接受SUBSCRIBE请求. 在应用程序中,我有一个SUBSCRIBE的处理程序,即@Componentpublic class SubscribeStompEventHandler implements ApplicationListener<SessionSubscribeEvent> {@Overridepublic void onApplicationEvent(SessionSubscribeEvent event) {}}我用来验证订阅. 如果订阅无效,例如,当前用户看不到该订阅,我希望Broker(我使用SimpleMessagingBroker)“忘记”该订阅,或者最好不...

java – 如何让spring boot嵌入式tomcat返回200 OK for base url?【代码】

我的应用程序部署在http://123.87.65.23:8080.上下文路径是在application.properties中配置的/ myapp.所以如果我访问http://123.87.65.23:8080,我会得到404.但如果我访问http://123.87.65.23:8080/myapp/health,我会得到200预期. 我们的运营团队监控基本网址(http://123.87.65.23:8080)200 OK.我有两个选择: >当我点击http://123.87.65.23:8080时,返回200 OK.无需回复.>或者以某种方式将请求http://123.87.65.23:8080代理到我的Sp...

java – Spring Data Mongo:如何保存批处理忽略所有重复的键错误?【代码】

我有以下域对象:@Document class Foo {@Idprivate final String bar;private final String baz;// getters, setters, constructor omitted }插入如下:Collection<Foo> foos = ...; mongoTemplate.insert(foos, Foo.class);如何在一次调用中保存所有结果而忽略所有重复的键异常?解决方法:我搜索了spring数据mongo文档和其他资源,但没有找到预期的答案. 看起来像Mongo插入批处理文档,直到满足唯一键约束,并由DB来决定. 因此,例如,...

java – Spring Boot和Thymeleaf Neko HTML错误【代码】

我试图用Spring Boot和Thymeleaf运行一个例子.我收到了这个错误:There was an unexpected error (type=Internal Server Error,status=500). Cannot perform conversion to XML from legacy HTML: ThenekoHTML library is not in classpath. nekoHTML 1.9.15 or newer isrequired for processing templates in “LEGACYHTML5” mode这些是我的依赖:<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-bo...

java – 在Spring Sockjs应用程序上手动设置传输类型【代码】

我需要在非JEE7兼容服务器上安装应用程序.我正在使用Spring Stomp SocksJs进行实时通知. 我的代码看起来像这样:@Configuration @EnableWebSocketMessageBroker public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {@Overridepublic void configureMessageBroker(MessageBrokerRegistry config) {config.enableSimpleBroker("/topic");config.setApplicationDestinationPrefixes("/app");}@Overridep...

java – Spring Annotations – 注入对象的Map【代码】

使用XML注释,我使用下面的配置注入一个地图 – <bean id = "customerfactory" class = "com.brightstar.CustomerFactory"><property name = "getCustomerMap"><map key-type = "java.lang.String" value-type = "com.brightstar.CustomerImpl"><entry key = "DEFAULT" value-ref = "getDefaultImpl"></entry><entry key = "PERSON" value-ref = "getPersonImpl"></entry><entry key = "COMPANY" value-ref = "getCompanyImpl"></en...