Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move resource file #128

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ LABEL \
description="This image contains a sample application that displays the Java system properties and demonstrates MicroProfile Config, Health and Metrics."

COPY --chown=1001:0 src/main/liberty/config/ /config/
COPY --chown=1001:0 resources/ /output/resources/

RUN features.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import java.io.StringReader;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.eclipse.microprofile.config.spi.ConfigSource;

public class CustomConfigSource implements ConfigSource {

String fileLocation = System.getProperty("user.dir").split("target")[0]
+ "/resources/CustomConfigSource.json";
String fileLocation = "META-INF/CustomConfigSource.json";

@Override
public int getOrdinal() {
Expand Down Expand Up @@ -83,7 +84,8 @@ public Map<String, String> getProperties() {
public String readFile(String fileName) {
String result = "";
try {
BufferedReader br = new BufferedReader(new FileReader(fileName));
InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
Expand Down