This repository was archived by the owner on May 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Static resources not included in Jar #704
Copy link
Copy link
Open
Description
Hi Folks,
Been doing a bit of fiddling about with generating a Jar and then deploying it to a separate server and found a bit of an issue.
Steps to reproduce:
- Open command prompt
- cd marklogic-samplestack\appserver\java-spring
- gradlew assemble
- cd build\libs
- java -jar samplestack-1.1.0.jar
(NB, don't run it from the java-spring folder)
Expected result:
- Application starts up using embedded tomcat and serves all content
Actual Result:
- Application starts up and doesn't throw any errors, but can't access the home page (index.html. There is no static content in the jar file (extracting the jar confirms this)
Potential Fix:
It seems the reason for this is by default gradle doesn't include the "static" folder in its current location
Steps
- Move "static" folder into src/main/resources
- Rebuild -> now present in Jar
- Update marklogic-samplestack\shared\js\dev-tasks\context.js to:
var javaStaticDir = path.resolve(
projectRoot, 'appserver/java-spring/src/main/resources'
);
Keen to hear if people think this is a sensible approach or if there's an obviously better way to go about it.
Here's a related stackoverflow answer:
http://stackoverflow.com/questions/29172612/spring-boot-app-not-serving-static-content
The spring boot docs mention this:
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content
Thanks,
James
Metadata
Metadata
Assignees
Labels
No labels