java - Spring Boot app packaged as WAR deployed on Jetty 9.2 -


i have created spring boot application. runs in standalone mode. next step produce war file can loaded embedded jetty server instance (version 9.2).

i managed generate war file. however, default spring boot annotations not interpreted , spring boot not loading (i.e. when open url associated app, war files listed).

one manner found make spring boot start consists in adding web.xml file in web-inf application context enables component-scan. way, spring boot loaded embedded jetty server. however, looks application properties (from meta-info/application.properties file) not evaluated: instance spring.jpa.hibernate.ddl-auto=update has no effect , create-drop used instead.

i able reconfigure few beans make application properties work not last 1 related hibernate. looks spring auto configurations not enabled.

is there mean make spring boot application packaged war deployed on jetty without web.xml or @ least generic configuration enables spring auto configurations?

below code related creation of embedded jetty server:

server server = createhttpserver(properties, restport, httpsenabled); server.setstopatshutdown(true);  handlerlist handlerlist = new handlerlist(); addwarstohandlerlist(handlerlist); server.sethandler(handlerlist); server.start(); 

the method addwarstohandlerlist calling following method war archives deploy on application server:

private static void addwarfile(handlerlist handlerlist, file file) {     string contextpath = "/" + filenameutils.getbasename(file.getname());     webappcontext webapp = createwebappcontext(contextpath);     webapp.setwar(file.getabsolutepath());     handlerlist.addhandler(webapp);     logger.debug("deploying " + contextpath + " using war file " + file); } 

hereafter, web configuration. first web.xml:

<?xml version="1.0" encoding="utf-8"?>  <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"          version="3.1">      <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>/web-inf/applicationcontext.xml</param-value>     </context-param>      <servlet>         <servlet-name>appservlet</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>         <init-param>             <param-name>contextattribute</param-name>             <param-value>org.springframework.web.context.webapplicationcontext.root</param-value>         </init-param>         <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>appservlet</servlet-name>         <url-pattern>/</url-pattern>     </servlet-mapping>  </web-app> 

and applicationcontext.xml file used previous one:

<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"        xsi:schemalocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-4.2.xsd     http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-4.2.xsd">      <context:component-scan base-package="my.package"/>      <bean id="appconfigproperties"           class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">         <property name="location" value="classpath:application.properties"/>     </bean>      <bean id="filtermultipartresolver" class="org.springframework.web.multipart.commons.commonsmultipartresolver">         <property name="maxuploadsize" value="100000000"/>     </bean>  </beans> 

any comment, suggestion, etc. welcome.

spring auto-configurations loaded application.properties file not. solution use @propertysource application class:

@propertysource("classpath:application.properties") public class application extends webmvcconfigureradapter { ... }


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -