Skip to content

This repo shows how to externalize / override public content of already packaged spring-boot web abb without repackaging.

License

Notifications You must be signed in to change notification settings

daggerok/externalize-spring-boot-public-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

externalize-spring-boot-public-path Build Status

Note
see an example in .travis.yml

To externalize static resources folder you can run app without public folder packaged and later create such folder with needed content near to jar file

customize static resources locations:

by default spring is using folders static/ and public/:
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
so you cd to application jar file folder and can create here needed one:
mkdir -p demo
cd demo/
curl https://start.spring.io/starter.zip -d dependencies=web | tar -xzvf -
bash ./mvnw clean package
cd target/
mkdir -p public
echo "<html><body>Hello</body></html>" > ./public/index.html
java -jar *.jar
http :8080

tree .
.
├── demo-0.0.1-SNAPSHOT.jar
└── public
    └── index.html
or create public folder where you are relatively to jar file (public folder located in $PWD):
mkdir -p demo
cd demo/
curl https://start.spring.io/starter.zip -d dependencies=web | tar -xzvf -
bash ./mvnw clean package
mkdir -p public
echo "<html><body>Hello</body></html>" > ./public/index.html
java -jar ./target/*.jar
http :8080

tree .
.
├── public
│   └── index.html
└── target
    └── demo-0.0.1-SNAPSHOT.jar
or simply use spring boot executable launch scripts (public folder located near jar-file):
wget https://start.spring.io/starter.zip -O /tmp/gradle-demo.zip --post-data="dependencies=web&type=gradle-project"
mkdir -p /tmp/gradle-demo
unzip /tmp/gradle-demo.zip -d /tmp/gradle-demo
cd /tmp/gradle-demo/
echo 'bootJar { launchScript() }' >> build.gradle
bash gradlew build
bash ./build/libs/*.jar
http :8080 || true

mkdir -p ./build/libs/public
echo "<html><body>Hello</body></html>" > ./build/libs/public/index.html
bash ./build/libs/*.jar
http :8080

tree .
.
└── build
    └── libs
        ├── demo-0.0.1-SNAPSHOT.jar
        └── public
            └── index.html
for maven pom.xml
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
    </plugins>
</build>

About

This repo shows how to externalize / override public content of already packaged spring-boot web abb without repackaging.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published