10

We used to specify display-name in our web.xml Currently we don't have a web.xml (and adding one seems to break the application)

We are using spring boot / spring 4 / java 7 / maven3 to develop rest services.

Can anyone tell me how the display-name can be be set ? For example from within the java code / SpringBootServletInitializer ?

note: I currently don't have any @WebServlet tags

After adding web.xml below, tomcat manager will show the display-name, but when opening my application I get 404. It seems adding web.xml breaks my app.

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0">
<display-name>MyT2ConfigServer</display-name>
  <description>MyT2ConfigServer description</description>
</web-app>
Raymond Domingo
  • 173
  • 2
  • 9
  • 2
    You cannot, you have to use a `web.xml` for that. One of the things that is missing from java bases configuration as well as error-pages and some session settings. – M. Deinum Nov 18 '14 at 12:45
  • thank you for responding. should you be able to add a web.xml and also use SpringBootServletInitializer ? – Raymond Domingo Nov 18 '14 at 12:49
  • 1
    Yes one doesn't (by default) rule out the other. If you add the `metadata-complete="true"` to your web.xml no detection will be done, however by default it will. – M. Deinum Nov 18 '14 at 12:52

2 Answers2

5

Since SpringBoot v1.3.1.RELEASE, you can do it via the server.display-name property.

See https://github.com/spring-projects/spring-boot/issues/2600

EDIT 2019-10-24 : Since SpringBoot v2.0.0 RELEASE you can do it via the server.servlet.application-display-name property

See this commit : https://github.com/spring-projects/spring-boot/commit/0c1aac14a077685ce6a6c2c0d7066255a7433365

morellet.d
  • 583
  • 6
  • 18
0

After adding web.xml I ran into an unrelated problem caused by some other change I made... When I fixed this other problem all was fine and I could use above web.xml as suggested by M.Deinum.

Raymond Domingo
  • 173
  • 2
  • 9