|
23 | 23 | import java.nio.file.Paths; |
24 | 24 | import java.sql.SQLException; |
25 | 25 | import java.util.Comparator; |
| 26 | +import java.util.HashMap; |
| 27 | +import java.util.Map; |
26 | 28 | import java.util.Properties; |
27 | 29 |
|
28 | 30 | import de.doubleslash.keeptime.model.Authorities; |
@@ -591,8 +593,11 @@ private void handleApiOn() { |
591 | 593 |
|
592 | 594 | createAndSaveUser(username, password); |
593 | 595 |
|
594 | | - propertyWrite("server.port", authPort.getText()); |
595 | | - setWebApplicationType(""); |
| 596 | + Map<String, String> propertiesToUpdate = new HashMap<>(); |
| 597 | + propertiesToUpdate.put("spring.main.web-application-type", ""); |
| 598 | + propertiesToUpdate.put("server.port", authPort.getText()); |
| 599 | + |
| 600 | + propertyWrite(propertiesToUpdate); |
596 | 601 | } |
597 | 602 |
|
598 | 603 | private void setWebApplicationType(String value) { |
@@ -621,9 +626,29 @@ private void propertyWrite(String key, String value) { |
621 | 626 | Properties properties = new Properties(); |
622 | 627 | try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propertiesFilePath); |
623 | 628 | FileOutputStream outputStream = new FileOutputStream(propertiesFilePath)) { |
| 629 | + |
624 | 630 | properties.load(inputStream); |
625 | 631 | properties.setProperty(key, value); |
626 | 632 | properties.store(outputStream, null); |
| 633 | + |
| 634 | + } catch (IOException e) { |
| 635 | + e.printStackTrace(); |
| 636 | + } |
| 637 | + } |
| 638 | + |
| 639 | + private void propertyWrite(Map<String, String> propertiesToUpdate) { |
| 640 | + Properties properties = new Properties(); |
| 641 | + try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propertiesFilePath); |
| 642 | + FileOutputStream outputStream = new FileOutputStream(propertiesFilePath)) { |
| 643 | + |
| 644 | + properties.load(inputStream); |
| 645 | + |
| 646 | + for (Map.Entry<String, String> entry : propertiesToUpdate.entrySet()) { |
| 647 | + properties.setProperty(entry.getKey(), entry.getValue()); |
| 648 | + } |
| 649 | + |
| 650 | + properties.store(outputStream, null); |
| 651 | + |
627 | 652 | } catch (IOException e) { |
628 | 653 | e.printStackTrace(); |
629 | 654 | } |
|
0 commit comments