jjzjj

spring-annotations

全部标签

java - 具有 XML 配置支持的基于 Spring Java 的 Servlet 容器初始化(web.xml 替代方案)?

我最近想迈出一大步,将所有内容都移至基于Java的配置。到目前为止工作完美。只有一个问题。有一个来自Spring的WebApplicationInitializer接口(interface),它实际上是第一个web.xml替代AFAIK:publicclassMyWebApplicationInitializerimplementsWebApplicationInitializer{@OverridepublicvoidonStartup(ServletContextcontainer){XmlWebApplicationContextappContext=newXmlWebAppli

xml - Spring xml配置启用@Async而不启用@Scheduled

使用Spring的xml配置,如何启用对@Async的扫描注释而不启用@Scheduled扫描注释?通常,您会使用同时启用两者但我试图仅在特定的Spring配置文件处于事件状态时启用调度。使用SpringJavaConfig,可以使用@EnableAsync和@EnableScheduling分别地。我正在维护一个已经存在了几年的项目,它只使用基于xml和注释的配置,我不想将JavaConfig添加到组合中,除非这是唯一的方法。 最佳答案 不使用命名空间,而是手动添加相应的bean。org.springframework.sched

java - 基于另一个 bean 的 Spring Conditional Bean 创建

我正在尝试使用Spring3.2和XML配置找到一种仅在另一个bean/属性的值为true时才创建bean的方法。.....createsomebeans我见过一些使用SpringEL的稍微类似的例子,但没有一个是完全这样的…… 最佳答案 您可以使用配置文件。一个人可以同时激活多个配置文件或选择不激活任何配置文件。要激活有多种方法,但要以编程方式执行此操作,我们需要在web.xml中添加一个初始化程序contextInitializerClassescom.test.MyCustomInitializerMyCustomInitia

java - 没有 jpa 的 Spring 和 Hibernate

对于我的新项目,我计划使用Hibernate5和Spring4,并且一如既往地喜欢分成不同的层/项目。Gradle依赖项:"org.springframework:spring-webmvc:4.2.1.RELEASE","org.springframework:spring-orm:4.2.1.RELEASE",'org.hibernate:hibernate-core:5.0.2.Final','mysql:mysql-connector-java:5.1.36'有一个API项目,其中包含一个User.class。在我看来,这个用户类不能对数据库层使用任何注释。它不得指定@Tabl

java - Spring:根据 XSD 模式验证 REST Controller

目前我有带有以下代码的RestControllerpackagebe.smartask.api;importbe.smartask.api.model.NumberValue;importbe.smartask.api.model.TextValue;importbe.smartask.api.model.Translations;importorg.springframework.http.HttpStatus;importorg.springframework.http.ResponseEntity;importorg.springframework.web.bind.annota

java - 如何在 Spring 集成中使用 JAVA 配置创建 xslt-transformer?

我在Spring-Integration中有以下xslt-transformer。如何使用JavaConfig进行相同的配置? 最佳答案 @Transformer(inputChannel="input",outputChannel="output")@BeanpublicXsltPayloadTransformertransformer(){returnnewXsltPayloadTransformer(newClassPathResource("classpath:/test.xsl"),resultToDoc());}从另一边

java - Spring Tool Suite 应用程序上下文 xml 错误,即使所有 bean 似乎都按预期工作

我正在一个spring应用程序上下文xml中配置jpa和jpa存储库。如果我同时拥有和然后SpringToolSuite在第1行显示错误Referencedfilecontainserrors(http://www.springframework.org/schema/context/spring-context-4.0.xsd).Formoreinformation,rightclickonthemessageintheProblemsViewandselect"ShowDetails..."点击显示详细信息后,我得到了这个:Theerrorsbelowweredetectedwhe

java - hsqldb 的 spring applicationContext 中的数据源

我正在我的应用程序中加载Spring3.2.2,在applicationContext.xml中:但是,我收到以下异常:344[main]INFOorg.springframework.beans.factory.support.DefaultListableBeanFactory-Destroyingsingletonsinorg.springframework.beans.factory.support.DefaultListableBeanFactory@120d62b:definingbeans[org.springframework.aop.config.internalAu

c# - 如何解析 xs :annotation from the xs:choice using the System. Xml.Schema

我正在尝试在xs:choice中添加注释元素。根据xs:choice语法,这是可能的。我在BTW中找不到带有注释的选择样本。我当前版本的xsd文件包含一个元素:Headline_VVVVVHelpText_VVVVV但是,在解析xsd文件时,对象System.Xml.Schema.XmlSchemaChoice的Annotation始终为null。代码部分:publicListParse(XmlTextReaderxsdReader){try{//prepareschemasetforschemavalidationandrawtemplatexsd"enrichment"XmlSch

xml - Spring Servlet-Context.xml 报错Cannot locate BeanDefinitionParser for element [import]

我有一个由Eclipse中的STS插件生成的spring项目,我试图导入一个与servlet-context.xml位于同一目录中的spring-ws文件,但出现错误。下面列出了servlet上下文文件我得到的错误是在此行找到多个注释:配置问题:找不到元素[import]的BeanDefinitionParser 最佳答案 在您的XML中,您已将spring-mvc.xsd作为前导。mvc命名空间不包含元素import,但是spring-beans.xsd包含。您需要将beans前缀添加到import元素以使其工作。就像来自同一命名