草庐IT

spring-boot-starter-data-redis

全部标签

java - Spring-Social/Twitter——ConnectController 不响应/连接?

好吧,我现在一直在纠结(至少看起来是这样!)试图找出我做错了什么:我有一个Java项目,我想允许登录的用户(通过正常的启用Spring-SecurityJDBC的存储库)向我的应用程序授予对其Twitter帐户的访问权限。我已经通过Twitter等注册了一个应用程序,并拥有secret和访问key以及测试所需的所有其他内容,但是,尽管阅读了所有文档并尝试了所有配置,即使我的spring配置创建了ConnectController,每当我点击/connect/twitter时,我都会收到404(未找到),尽管在Tomcat中出现上下文期间绝对没有生成错误,并且其他一切正常(即我所有的be

java - 空请求正文未被 Spring @RequestBody @Valid 注释捕获

我目前在Spring中遇到了@RequestBody注释的问题。我目前在我的模型上正确设置了所有验证注释,并且它们在发布对象时效果很好。即使发布的请求正文完全为空或空对象“{}”,一切都按预期工作。当有人试图发布“null”的请求正文时,问题就出现了。这以某种方式通过了@Valid注释并且没有被捕获,导致当我尝试访问该对象时出现NullPointerException。我在下面粘贴了我的Controller的片段。@Secured({ROLE_ADMIN})@RequestMapping(method=RequestMethod.POST,consumes={MediaType.APP

java - Spring:缺少 JPA 元模型

我无法理解带有JPA存储库的简单SpringMVC项目出了什么问题。能否给个提示。域:packagecom.test.app;@Entity@Table(name="foo_table")publicclassFooDomain{@Id@Column(name="id",unique=true,nullable=false)privateIntegerid;@Column(name="text",nullable=false)privateStringtext;//getters&settershere...存储库packagecom.test.app;@RepositoryDefin

java - 使用 Spring KeyGenerator 生成唯一的缓存 key 不起作用

当我的缓存键在Spring中使用@Cacheable注释发生冲突时,我遇到了问题。例如,使用以下两种方法:@Cacheable("doOneThing")publicvoiddoOneThing(Stringname){//dosomethingwithname}@Cacheable("doAnotherThing")publicvoiddoAnotherThing(Stringname){//dosomeotherthingwithname}这是我的缓存配置,我在其中添加了一个keyGenerator和一个cacheManagerbean:@Configuration@EnableC

java - 带有 MVC 的 Spring Boot SOAP Web 服务

我想结合Spring指南中的两个Spring(spring-boot)应用程序:https://spring.io/guides/gs/serving-web-content/https://spring.io/guides/gs/producing-web-service/不幸的是,这些例子不能一起工作。servlet调度程序有问题。添加dispatcherServletbean后-MVCservlet不工作(错误404)。@BeanpublicServletRegistrationBeandispatcherServlet(ApplicationContextapplication

java - Spring 的多线程

我正在尝试进入spring多线程,我有几个问题。我在ThreadRating类中有可运行的方法。现在我不确定使用它的最佳方式。我找到的选项1:privatevoidupdateRating(){ExecutorServiceexecutor=Executors.newFixedThreadPool(10);for(inti=0;i这似乎运行良好。for循环后,等待线程执行完毕结束。我尝试的第二个选项privateTaskExecutortaskExecutor;publicUpdateBO(TaskExecutortaskExecutor){this.taskExecutor=task

java - 是否可以在单元测试期间禁用 Spring 的 @Async?

我有一个用@Async注释的方法说@AsyncpublicvoidmakeFood(){}但我只是想测试该方法的逻辑。是否可以同步测试? 最佳答案 是的,只要你的配置没有@EnableAsync,方法就会同步执行。 关于java-是否可以在单元测试期间禁用Spring的@Async?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/29929824/

java - Spring Data Neo4j 4 中的分页和排序

SDN4中的自定义查询是否支持分页?如果是,它是如何工作的?如果没有,是否有变通办法?我有以下SpringDataNeo4j4存储库:@RepositorypublicinterfaceTopicRepositoryextendsGraphRepository,IAuthorityLookup{//othermethodsomitted@Query("MATCH(t:Topic)-[:HAS_OFFICER]->(u:User)"+"WHEREt.id={0}"+"RETURNu")publicPagetopicOfficers(LongtopicId,Pageablepageable

java - 如何在单个注解中组合多个 Spring 测试注解?

我在我的测试类上使用SpringBoot方便的注释来进行集成测试。@RunWith(SpringJUnit4ClassRunner.class)@SpringApplicationConfiguration(classes=Config.class)@IntegrationTest@Sql({"classpath:rollback.sql","classpath:create-tables.sql"})@Transactional我发现在每个测试类上复制/粘贴整个block非常难看,所以我创建了自己的@MyIntegrationTest注释@SpringApplicationConfi

java - Spring security 授权从数据库请求值

我想在服务器启动时从数据库配置授权请求值。目前我在Java类文件中给出硬核值,有什么方法可以从数据库中读取相同的值。示例代码如下:protectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().antMatchers("/resources/**","/signup","/about").permitAll().antMatchers("/admin/**").hasRole("ADMIN").antMatchers("/db/**").access("hasRole('ADMIN')an