0

I'm a junior Spring Boot developer and I have issues with integration of web.xml file in a project.

Is it possible to add that XML in my project without destroying my old configuration?

help-info.de
  • 6,695
  • 16
  • 39
  • 41

1 Answers1

0

You could simply create directories webapp/WEB-INF in the main folder of your project and put web.xml file into WEB-INF. That should be enough for Spring-boot to take web.xml into account BUT as it was mention in the comment you don't need to do that in 99.99999% of situations of modern web application development.

If you add spring-boot-starter-web dependence into your maven or gradle configs you will have a fully configured TomCat web server inside your application and you can specify all options of it in application.properties file of your application of with some special classes.

Try to google about things I mention in this post and also came throug this tutorial of basic Spring boot web application https://spring.io/guides/gs/spring-boot/

Alexey Usharovski
  • 1,404
  • 13
  • 31
  • thank you fo the help, i know that in the most of modern webapp development is not necessary but i need for integrate an ejb configuration – Aldo Masciantonio Dec 13 '19 at 09:56
  • Could you provide a bit more details about the integration you want to have? Do you plan to deploy a spring-boot application to some JavaEE application server as `war`? – Alexey Usharovski Dec 13 '19 at 09:59
  • i need to deploy my spring boot application on a weblogic server, and i need to deploy an ear that contain a war of my application and an ejb libreries – Aldo Masciantonio Dec 13 '19 at 10:03
  • Ok. I guess you know that you can specify `war` as a target artifact in Spring boot initializer. And how I mentioned in my answer you can create in spring-boot application well known JavaEE folder structure to put there all server-specific configuration XMLs. If something going wrong, feel free to ask me here. I guess I can help. – Alexey Usharovski Dec 13 '19 at 10:21
  • i tried to use @ImportResource("classpath:web.xml") to import web xml but it give me an error like this: java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource [web.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; lineNumber: 1; columnNumber: 1; Fine del file anticipata. Caused by: org.xml.sax.SAXParseException: Fine del file anticipata. i – Aldo Masciantonio Dec 13 '19 at 10:25
  • i tried to validate my xml, it seems to be correct. I dont understand where the problem is – Aldo Masciantonio Dec 13 '19 at 10:27
  • I suppose for such kind of problem you should update this question or ask the new one. Very inconvenient to post big code snippets in comments. – Alexey Usharovski Dec 13 '19 at 11:39
  • 1
    i think i've found a solution to integrate web.xml in my project, at least i think that the problem was the version of xml header. thank you very much for the help that you give to me :D – Aldo Masciantonio Dec 13 '19 at 11:47