@Component
public class AppService {
@Value("1")
private int version;
@Value("classpath:/app.properties")
private Resource resource_app;
private String app;
@Value("classpath:/logo.txt")
private Resource resource;
private String logo;
@PostConstruct
public void init() throws IOException {
try (var reader = new BufferedReader(
new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8))) {
this.logo = reader.lines().collect(Collectors.joining("\n"));
}
new InputStreamReader(resource_app.getInputStream(), StandardCharsets.UTF_8))) {
this.app =reader.lines().collect(Collectors.joining("\n"));
public void printLogo() {
System.out.println(logo);
System.out.println("app.version: " + version);
public void printApp() {
System.out.println(app);
@PreDestroy
public void shutDown() {
System.out.println("end!");
Sign in to make a reply
CC不爱睡觉
@Component
public class AppService {
@Value("1")
private int version;
@Value("classpath:/app.properties")
private Resource resource_app;
private String app;
@Value("classpath:/logo.txt")
private Resource resource;
private String logo;
@PostConstruct
public void init() throws IOException {
try (var reader = new BufferedReader(
new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8))) {
this.logo = reader.lines().collect(Collectors.joining("\n"));
}
try (var reader = new BufferedReader(
new InputStreamReader(resource_app.getInputStream(), StandardCharsets.UTF_8))) {
this.app =reader.lines().collect(Collectors.joining("\n"));
}
}
public void printLogo() {
System.out.println(logo);
System.out.println("app.version: " + version);
}
public void printApp() {
System.out.println(app);
}
@PreDestroy
public void shutDown() {
System.out.println("end!");
}
}