【zbb20170228_spring_web.xml】教程文章相关的互联网学习教程文章

java-应用程序上下文XML文件中的Spring util属性【代码】

我正在像这样在app-context.xml中描述属性文件:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:task="http://www.springframework.org/schema/task"xmlns:util="http://www.springframe...

java-线程“ main”中的异常org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException【代码】

最近,我正在学习Spring框架.所以我正在尝试检查依赖注入在Spring框架中如何工作.结果,我创建了一个新的Java项目,并使用基于构造函数XML的配置练习了依赖注入代码.运行我的项目后,我收到此错误….Line 24 in XML document from class path resource [com/mir00r/beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 9; cvc-complex-type.2.3: Element ‘beans’ cannot have...

《Java Spring框架》SpringXML配置详解【代码】【图】

Spring框架作为Bean的管理容器,其最经典最基础的Bean配置方式就是纯XML配置,这样做使得结构清晰明了,适合大型项目使用。Spring的XML配置虽然很繁琐,而且存在简洁的注解方式,但读懂XML配置文件对我们来说依然很重要,尚且对于老系统维护必不可少的面对XML配置。 下面通过案例来理解XML配置。 案例:(一个基础的Bean)public class Pet {private String petType;private String color ;public String getColor() {return color...

java-如何检测未使用XML配置的spring bean?

我有一个Java项目,其中存在许多.xml文件. 所有这些xml文件都包含许多bean. 未使用的测试是: >已定义但从未注入的bean.>注入但未在代码中调用的bean.>已定义但从未加载到Spring上下文中的bean. 问题 >如何确定使用或不使用哪个bean?>是否有实用程序可以做到这一点?解决方法:没有工具可以检测xml文件中未使用的springbeans.您可以使用Spring Tools Suite进行检测.但是检查花费了太多时间.

java-在Spring Boot中的同一pom.xml中管理H2和Postgres【代码】

我正在使用Spring Boot开发一个微服务应用程序.我的应用程序将使用Postgres DB进行生产配置,并使用Spring Boot自动测试H2 DB.因此,我的pom.xml包括两个依赖项(H2 Postgres).我尝试将H2依赖项与tes范围关联,并将Postgres与运行时关联,如下所示:<dependency><groupId>com.h2database</groupId><artifactId>h2</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.postgresql</groupId><artifactId>postgresql...

将xml发布到spring REST端点不会被解组到相关的Java对象中【代码】

我有一个给定xsd的项目.我使用xjc编译器生成Java类.然后,我用XmlRootElement属性注释该类.我已经在AnnotationMethodHandlerAdapter中用Jaxb2编组/解组bean配置了sevlet.当我发送不带名称空间的xml时,出现415错误. 源代码如下文件-web.xml<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/n...

Java / Spring:使用XML“标记” Bean以按类和标记获取特定的Bean【代码】

我有几个文件组成的大型XML配置. 我需要让bean实现特定的接口.但是有几种实现方式,所以我必须选择.我想用特殊的“标签”来标记bean,以便轻松获得它:<bean class="myInterfaceImpl1" tag="beanForMe" /> <bean class="myInterfaceImpl2" /> <bean class="myInterfaceImpl3" />T get(Class<T> clazz) {return factory.getBean(clazz, "beanForMe"); //Returns first one }春天有没有类似的东西? 我发现2解决方法.首先是使用特殊标...

java-如何在Spring JUnit中正确配置WEB-INF / spring / webmvc-config.xml测试【代码】

我有一个基于Maven的Spring 3.0项目. Web应用程序的Spring配置文件位于/\u0026lt;proj\u0026gt;/src/main/webapp/WEB-INF/spring/webmvc-config.xml. 现在,我想进行一个JUnit测试,检查是否可以启动上下文.但是我不知道如何以一种正确的方式在@ContextConfiguration标记中指定该文件的位置. 我在做:@RunWith(SpringJUnit4ClassRunner.class) @Transactional() @ContextConfiguration({"classpath:META-INF/spring/application-cont...

java-Spring容器XML配置参考可以使用另一个bean的属性吗【代码】

在这里我正在编写一个spring应用程序,在这里我想做的是这样的:<bean id="sqlClient" class="com.braoda.dao.sqclient.SqlclientWapper"><property name="dataSource" ref="dataSource"/></bean><bean id="userDao" class="com.braoda.dao.user.UserDaoImpl"><property name="sqlSession" ref="***sqlClient.SqlSessionFactoryBean***" />就像代码一样,我想使用“ ref”中的spring Xml属性配置,但是“ ref”不是bean,而是bean的属...

java-spring.web服务在web.xml中的配置?【代码】

我正在使用spring-ws,并且我的web.xml中具有以下配置<servlet><servlet-name>spring-ws</servlet-name><servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class><init-param><param-name>**transformWsdlLocations**</param-name><param-value>true</param-value></init-param></servlet><servlet-mapping><servlet-name>spring-ws</servlet-name><url-pattern>/*</url-pattern></servlet-...

java-Spring Tool Suite应用程序上下文xml错误,即使所有bean似乎都可以正常工作【代码】

我正在Spring应用程序上下文xml之一中配置jpa和jpa存储库. 如果我同时拥有< jpa:repositories base-package =“ ...” />和< context:component-scan base-package =“ ...” />然后Spring Tool Suite在第1行显示错误 引用的文件包含错误(http://www.springframework.org/schema/context/spring-context-4.0.xsd).有关更多信息,请右键单击 问题视图,然后选择“显示详细信息…” 在单击显示详细信息后,我得到以下信息:The errors...

java-如何在Spring xml文件中使用多个属性占位符【代码】

我有一个关于Spring如何处理多个属性占位符的问题. 我有这段代码:<context:property-placeholder location="classpath:dir1/${myapp.system.property}.properties"/>属性myapp.system.property是已定义的System属性. 例如,如果将其定义为“ devsystem”,则将导入devsystem.properties中定义的所有属性,并可以在下面的代码中使用它们. 现在,我想拥有另一个属性文件,其名称由devsystem.property文件中的属性定义:<context:property...

java-如何使用不带XML的Spring启动H2 WebServer?【代码】

我目前正在使用所有Spring配置作为注释,我想将以下内容转换为注释:<bean id="h2Server" class="org.h2.tools.Server" factory-method="createTcpServer" init-method="start" destroy-method="stop" depends-on="h2WebServer"><constructor-arg value="-tcp,-tcpAllowOthers,-tcpPort,9092"/> </bean> <bean id="h2WebServer" class="org.h2.tools.Server" factory-method="createWebServer" init-method="start" destroy-method=...

Spring Security XML Config与Java Config【代码】

我已经通过大量指南完成了Spring Security的XML配置.它应该拦截URL,并使用自定义过滤器通过ldap身份验证管理器提供身份验证. 所以这里是: <http create-session="stateless" auto-config='false' use-expressions="true"><anonymous enabled="true"/><intercept-url pattern="/index.html" access="permitAll()" method="GET"/><intercept-url pattern="/login" access="permitAll()" method="GET"/><custom-filter before="LA...

java-FXMLLoader初始化和SpringBoot-@Configuration【代码】

我有MVP将Spring Boot与JavaFX集成的教程中的一个问题 GitHub的:https://github.com/mvpjava YouTube的:https://www.youtube.com/watch?v=hjeSOxi3uPg 在Spring Boot应用程序启动后,有一个名为initialize()的公共方法,我不知道如何调用它.我在类和fxml文件中到处都可以找到对它的引用,但没有发现. 我想知道如何调用此方法,因为我还想对JavaFX控件进行一些初始化.我尝试使用@PostConstruct,但是这是错误的,因为所有bean都是在创建...