草庐IT

spring注入Bean

全部标签

java - Spring MVC后台进程

我有Perl背景,正在使用Spring编写我的第一个JavaMVC网络应用程序。我的网络应用程序允许用户提交订单,该应用程序通过调用第三方SOAP服务同步处理这些订单。该项目的下一阶段是允许用户提交批量订单(例如包含500行的CSV)并异步处理它们。这是我现有Controller的片段:@Controller@Service@RequestMapping(value="/orders")publicclassOrderController{@AutowiredOrderServiceorderService;@RequestMapping(value="/new",method=Req

java - 在 @Aspect 中使用 Spring @Profile

所以我想要的是在配置文件处于Activity状态时将特定的SpringAspect应用于我的类,但我找不到解决方案,我尝试了http://city81.blogspot.com/2012/05/using-spring-profile-with.html中提出的方法但是已经很老了,对我来说不起作用,我有一个用于测试的SpringStarted项目,我根据链接执行以下操作:配置应用程序:@Configuration@ComponentScan(basePackages={"demo","demo.aspect"})@EnableAutoConfiguration(exclude=AopA

java - Spring:@DateTimeFormat 在嵌套对象中被忽略

在我的示例中,当嵌套对象时,@DateTimeFormat注释被忽略:classPerson{privateDatebirthdate;//otherfields@DateTimeFormat(pattern="dd.MM.yyyy")publicDategetBirthdate(){returnbirthdate;}//Othergetters/setters}我有一个嵌套这个对象的类。classPersonGroup{privatePersonperson1;privatePersonperson2;//otherfields@ValidpublicPersongetPerson1

java - _version、_id 等的 spring-data-elasticsearch 元数据注释

使用@Id注释我可以添加id字段到我的模型对象,当我执行查询时,生成的模型对象将包含elasticsearch_id的值在@Id带注释的字段。但是,我还没有弄清楚如何获取其他文档元数据,例如_version.我尝试添加version字段到我的模型并用@Version注释它注释但什么也没发生,该字段仍然存在null.{"_index":"twitter","_type":"tweet","_id":"1","_version":1,"found":true,"_source":{"user":"kimchy","postDate":"2009-11-15T14:12:12","messa

java - Spring Boot - 处理 JSON 或 HTML 的错误 Controller

我有一个springboot应用程序。我有一个自定义错误Controller,它被映射到使用ErrorPage映射。映射主要基于HTTP状态代码,通常只是适本地呈现HTMLView。例如我的映射:@ConfigurationclassErrorConfigurationimplementsEmbeddedServletContainerCustomizer{@Overridepublicvoidcustomize(ConfigurableEmbeddedServletContainercontainer){container.addErrorPages(newErrorPage(Htt

java - 没有 [org.hibernate.SessionFactory] ​​类型的合格 bean

您好,我看到很多人遇到此类问题,但答案对我没有帮助,所以这是我的错误:我想我必须为sesssionFactory创建bean,但我是按照你在我的上下文文件中看到的方式创建的。这是spring、hibernate和angular项目,也许angular是个问题?请帮忙org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'homeController':Injectionofautowireddependenciesfailed;nestedexceptionisorg.sprin

java - Spring 4 : How to map RequestMapping URLs to particular controller

我编写了一个带有多个Controller的SpringMVC应用程序。在JSP上,我在表单上有action:并且相同的操作映射到Controller中的方法:@ControllerpublicclassTableControllerimplementsTableConstants{@RequestMapping(value="/saveTable")publicStringsaveTable(HttpServletRequestrequest,RedirectAttributesredirectAttributes){//...}}在我的web.xml中:Contextnameofth

java - 理解 Play 2.4 依赖注入(inject)

我有一些问题无法理解如何在Play2.4中应用依赖注入(inject)的新功能。我熟悉Guice,但在Play文档中没有解释实际绑定(bind)发生的方式和时间。我阅读了官方文档[1]并尝试使用最新的PlayMailer[2]作为示例。PlayMailer示例使用任意类并使用@inject注释MailerClient属性。当我尝试使用此类的对象时,属性为null,至少在调试时是这样。那么,我必须在何时何地进行实际注入(inject)?我对@singleton注释有同样的问题。它只是解释了如何注释它,而不是如何获取对象。我必须直接使用Guice,还是以某种方式集成它?[1]https:/

java - Akka Camel 和 Spring

我想结合Akka、ApacheCamel、Spring,但不知道在同一个项目中利用这三样东西的前进方向。我成功了1.writesomeworkingcodewithakka,akka-camelextensionandcamelroutes(JavaDSL)2.usecamelandspring(usejavaDSLbutspringfortransactionsandetc..)现在我需要结合1和2。谁能建议我实现这一目标的最简单方法?编辑有人说AKKA不再支持Spring,因为根据下面的链接,对象实例化存在冲突Whyspringintegrationdocforakkaexists

java - 如何使用 MockMVC 测试 Spring Rest 中的 Map 参数

在SpringRest中,我有一个RestController公开此方法:@RestController@RequestMapping("/controllerPath")publicclassMyController{@RequestMapping(method=RequestMethod.POST)publicvoidcreate(@RequestParameter("myParam")MapmyMap){//dosomething}}我想测试这个方法,使用MockMVC来自Spring://InitializethemapMapmyMap=init();//JSONifythem