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

NoClassDefFoundError:javax / xml / bind / UnmarshalException-Spring Security oauth2【代码】

目前,我正在致力于保护REST SpringBoot服务.我决定将oauth2与JWT一起使用.但是我在应用程序启动时遇到了一个奇怪的错误.我相信spring-security-core和spring-security-jwt版本必须存在一些错误.这是堆栈:Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.2017-11-17 11:47:34.428 ERROR 9604 --- [ main] o.s.boot.SpringApplication ...

java-Spring Maven项目结构pom.xml【代码】

我想获得使用Spring Boot设置多模块Maven项目的帮助. 如果我错了,请纠正我,但我已经读过Spring-Boot会读取启动主应用程序(用@SpringBootApplication注释,并用SpringApplication.run运行),并通过反射找到必要的类.这意味着它首先访问起始类,然后继续查找控制器,模型,存储库.如果是这样,如果我具有这样的项目结构,如何在每个模块的pom.xml中设置依赖项:app --src --pom.xmlcore --pom.xml--models ----/pom.xml--controllers ----/p...

java-具有节点功能的Spring int-xml:xpath-expression错误【代码】

我使用XMLSpy编写以下XPath来确定最长的字符串长度,并且它可以在XMLSpy中使用:string-length(//exception:ElementMessageAbcException/@exceptionMsg[not(string-length(.) < //exception:ElementMessageAbcException/@exceptionMsg/string-length(.))] )但是,当我在春季集成中将相同的字符串放入xpath-expression中时,会出错:org.springframework.beans.factory.BeanCreationException: Errorcreating bean with name ‘xpathMa...

java-如何在Spring XML元数据配置中为bean设置ServletContext属性【代码】

我尝试在此处搜索,但找不到解决方案.我有一些类似下面的XML元数据.<bean class="javax.servlet.ServletContext" id="servletContext" /><bean class="com.abc.ProductController"><property name="servletContext" ref="servletContext"/> </bean>通过这种配置,我得到一个例外,说“ javax.servlet.ServletContext”是一个接口,它无法使用id servletContext创建一个bean. ProductController类位于无法修改的某个jar中,但我希望将其作...

java-为什么在Tomcat加载和读取bean.xml时不能正确加载Spring AOP XML模式【代码】

我试图在Eclipse中使用Spring’s Schema Based AOP Support,并且尝试在Tomcat中加载配置时遇到错误. Eclipse中没有错误,并且自动完成功能对于aop命名空间正常工作,但是当我尝试将项目加载到eclipse中时,出现以下错误:09:17:59,515 WARN XmlBeanDefinitionReader:47 – Ignored XML validation warningorg.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document ‘http://www.springframework.org/sche...

java-Spring Boot外部配置和xml上下文【代码】

我想通过Spring Boot外部化我的配置,但我想继续部分使用xml上下文. 我的主类SpringServerApplication.java:@Configuration @PropertySources(value = {@PropertySource("classpath:/application.properties")}) public class SpringServerApplication {public static void main(String[] args) throws Exception {SpringApplication.run(new Object[] {SpringServerApplication.class, "classpath:ApplicationContextServer.xml" ...

java – 带有来自Jar的多个XML文件的Spring ApplicationContext【代码】

我需要使用当前Maven构建中的“main”applicationContext -a.xml创建一个ApplicationContext.另一个来自另一个maven构建的连接类,并在Maven依赖项包含的jar中预设. 这个想法:ApplicationContext context = new ClassPathXmlApplicationContext( new String[] {"classpath*:applicationContext-*.xml"});这应该从Classpath加载applicationContext-a.xml,因为它在同一个Project中.这有效. 然后应该从dependency-jar加载applicationC...

java – 从spring MVC控制器返回xml文件【代码】

我已经尝试了很多从控制器函数返回文件. 这是我的功能:@RequestMapping(value = "/files", method = RequestMethod.GET) @ResponseBody public FileSystemResource getFile() {return new FileSystemResource(new File("try.txt")); }我收到此错误消息:Could not write JSON:No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer(to avoid exception, disable Seriali...

java – 相当于@EnableAsync的Spring XML【代码】

有没有办法从XML打开Spring的Async配置?我看到的所有示例都使用程序化上下文声明并使用@EnableAsync 是否有XML等价物.在某些地方,我看到< context:annotation-config />正在使用,但这没有提到任何关于异步的东西. 我正在使用Spring 4.解决方法:你尝试过这个吗?<task:annotation-driven />

Spring Java Config:没有web.xml的Tomcat部署【代码】

我构建了一个没有任何XML的java配置的Spring MVC应用程序.我可以在笔记本电脑上部署和启动应用程序,没有任何问题.但是当我尝试在我的testserver(tomcat 7)上部署我的应用程序时,我收到以下消息:HTTP Status 404 - The requested resource (/[application context]/) is not available.我使用Eclipse Maven插件构建我的应用程序.是否可以在没有web.xml的情况下部署应用程序,如果没有,哪个是我真正需要的基本web.xml? Maven WAR插件...

java – Spring 4 REST程序,使用JAXB以XML格式返回List【代码】

我正在尝试使用Spring 4实现REST服务. REST方法将返回XML中的客户对象列表.该应用程序是注释驱动的. 对于XML,我使用了JAXB注释.根据我的理解,Spring会在找到JAXB注释时使用“Jaxb2RootElementHttpMessageConverter”开箱即用. 客户POJO:@XmlRootElement(name = "customer") public class Customer { private int id; private String name; private List favBookList; @XmlAttribute public int getId() {return id; } public void...

java – 使用Spring配置CXF以使用MOXY进行XML编组/解组【代码】

我有一个Java服务器应用程序,它使用CXF提供SOAP和REST Web服务.目前它使用JAX-B的参考实现进行XML编组/解组,但是我已将其配置为将Jettison替换为Jackson以进行JSON编组/解组.我使用Spring进行DI和应用程序上下文配置. REST Web服务配置代码段如下所示: web.xml中<servlet><display-name>Myapp REST Services</display-name><servlet-name>MyappWebServices</servlet-name><servlet-class>org.apache.cxf.transport.servlet.CXFSer...

如何在Spring xml配置文件中初始化Java Date对象?【代码】

考虑这个简单的例子 – public class Person{private String name;private Date dateOfBirth;// getters and setters here...}为了将Person初始化为Spring bean,我可以编写以下内容.<bean id = "Michael" class = "com.sampleDomainName.Person"> <property name = "name" value = "Michael" /> </bean>但是在上面的bean定义中,我该如何设置dateOfBirth? 例如.我想将dateOfBirth设置为1998-05-07解决方法:像任何其他POJO一样对待它...

spring – 如何在Java Config中注册SaltSource(无xml)【代码】

我正在设置一个不使用xml的新Web应用程序(没有web.xml,没有spring.xml).我几乎一切都工作,除了我无法弄清楚如何注册SaltSource.我需要用Java等效替换以下内容.<authentication-manager><authentication-provider user-service-ref="authService" ><password-encoder hash="sha" ref="myPasswordEncoder"><salt-source user-property="salt"/></password-encoder></authentication-provider> </authentication-manager>到目前为止,我...

java – JSF通过XML或代码进行Spring注入【代码】

我继承了一些JSF Spring代码,可以看到而不是通过faces-config.xml注入Spring bean<managed-bean>团队已经在代码中完成了它FacesContext facesContext = FacesContext.getCurrentInstance();ELResolver elResolver = facesContext.getApplication().getELResolver();MyClass myBean = (MyClass) elResolver.getValue(facesContext.getELContext(), null,ApplicationConstants.MY_BEAN_NAME);我更喜欢在xml中执行此操作 – 是否有任何...