Giter Site home page Giter Site logo

Comments (4)

philwebb avatar philwebb commented on March 28, 2024

There is a sample application showing war packaging [1]. The intention is that you should be able to change the package type and everything just works.

Are you able to put together a small sample showing the problem?

[1] https://github.com/SpringSource/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-traditional/pom.xml#L11

from spring-boot.

bijukunjummen avatar bijukunjummen commented on March 28, 2024

Hi Phil,
Here is a project that does not work cleanly for me - https://github.com/bijukunjummen/spring-boot-mvc-test.git

It starts up cleanly with "mvn spring-boot:run" and there is a endpoint available at http://localhost:8080/hotels/list

However if you start this up with "mvn jetty:run" using the jetty plugin, the endpoint fails with an exception that the autocreate of the tables failed -

Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: HOTEL
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.SchemaManager.getTable(Unknown Source)
    at org.hsqldb.ParserDQL.readTableName(Unknown Source)

from spring-boot.

dsyer avatar dsyer commented on March 28, 2024

You aren't using SpringApplication to load your context in the non-embedded case so you would have to add some initializers to match that behaviour. In particular you aren't loading and binding to the application.properties, so it isn't setting the ddl-auto property, and the SQL script is not being executed as a result. You could fix this in your web.xml (in the servlet declaration)

<init-param>
    <param-name>contextInitializerClasses</param-name>
    <param-value>org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer</param-value>
</init-param>

It's probably better though to add a SpringBootServletInitializer, since that way you are always going to get all the features of SpringApplication in your web context (then you would use a Servlet 3.0 container - so no need for web.xml). Your SampleWebApplication could extend SpringBootServletInitializer and just return an array containing its own class (that's a pretty common pattern for these "hybrid" builds").

from spring-boot.

bijukunjummen avatar bijukunjummen commented on March 28, 2024

Perfect, specifying the ApplicationContextInitializer works cleanly.

from spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.