+
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
server:
|
server:
|
||||||
port: 8081
|
port: 8083
|
||||||
ssl:
|
ssl:
|
||||||
key-store: classpath:keystore.jks
|
key-store: classpath:keystore.jks
|
||||||
key-store-password: QyKtWPZB
|
key-store-password: QyKtWPZB
|
||||||
@ -11,7 +11,7 @@ server:
|
|||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: kz_ccalm_weather
|
name: org_ccalm_weather
|
||||||
cache:
|
cache:
|
||||||
type: none
|
type: none
|
||||||
|
|
||||||
|
|||||||
9
pom.xml
9
pom.xml
@ -45,10 +45,15 @@
|
|||||||
<artifactId>logstash-logback-encoder</artifactId>
|
<artifactId>logstash-logback-encoder</artifactId>
|
||||||
<version>6.6</version>
|
<version>6.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!--dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20231013</version>
|
<version>20231013</version>
|
||||||
|
</dependency-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20240303</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Исключаю зависимость из другой библиотеки а то в логе конфликт -->
|
<!-- Исключаю зависимость из другой библиотеки а то в логе конфликт -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -90,6 +95,8 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
package org.ccalm.weather;
|
package org.ccalm.weather;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
@ -8,17 +11,66 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class MainController {
|
public class MainController {
|
||||||
|
|
||||||
|
@Value("${spring.application.name}")
|
||||||
|
String application_name = "";
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping("/")
|
@RequestMapping(value = "/",method = {RequestMethod.POST,RequestMethod.GET},produces = "application/json;charset=utf-8")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getIndex(Model model) {
|
public ResponseEntity<String> getIndex(Model model) {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try {
|
||||||
|
json.put("error_code",0);
|
||||||
|
json.put("error_message","");
|
||||||
|
json.put("error_marker",(String)null);
|
||||||
|
String buildDate="";
|
||||||
|
//String buildVersion="";
|
||||||
|
try {
|
||||||
|
InputStream inputStream = MainController.class.getClassLoader().getResourceAsStream("META-INF/build-info.properties");
|
||||||
|
if (inputStream != null) {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properties.load(inputStream);
|
||||||
|
buildDate = properties.getProperty("build.time");
|
||||||
|
//buildVersion = properties.getProperty("build.version");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
json.put("build_date",buildDate);
|
||||||
|
//json.put("build_version",buildVersion);
|
||||||
|
json.put("name",application_name);
|
||||||
|
//json.put("active_connections",dataSource.getHikariPoolMXBean().getActiveConnections());
|
||||||
|
//json.put("idle_connections",dataSource.getHikariPoolMXBean().getIdleConnections());
|
||||||
|
|
||||||
|
// Вывод всех зарегистрированных маршрутов в системе
|
||||||
|
ApplicationContext context = SpringContext.getApplicationContext();
|
||||||
|
if (context != null) {
|
||||||
|
RequestMappingHandlerMapping mapping = context.getBean(RequestMappingHandlerMapping.class);
|
||||||
|
Set<String> endpoints = mapping.getHandlerMethods().keySet().stream()
|
||||||
|
.map(info -> info.toString())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
System.out.println("=== Registered API endpoints ===");
|
||||||
|
endpoints.forEach(System.out::println);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok(json.toString());
|
||||||
|
|
||||||
|
/*
|
||||||
String buildDate="";
|
String buildDate="";
|
||||||
//String buildVersion="";
|
//String buildVersion="";
|
||||||
try {
|
try {
|
||||||
@ -38,6 +90,7 @@ public class MainController {
|
|||||||
The weather list is working! <br><a href=\"./geodatalist\">/geodatalist</a>
|
The weather list is working! <br><a href=\"./geodatalist\">/geodatalist</a>
|
||||||
""";
|
""";
|
||||||
return result;
|
return result;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
|
|||||||
19
src/main/java/org/ccalm/weather/SpringContext.java
Normal file
19
src/main/java/org/ccalm/weather/SpringContext.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package org.ccalm.weather;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SpringContext implements ApplicationContextAware {
|
||||||
|
private static ApplicationContext context;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||||
|
context = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ApplicationContext getApplicationContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user