How to configure display-name when no web.xml

6.4k Views Asked by At

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>
2

There are 2 best solutions below

0
On

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.

3
On

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