mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-29 12:34:28 +08:00
SpringBoot3升级 (#1947)
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
<artifactId>launchers-chat</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<start-class>com.tencent.supersonic.ChatLauncher</start-class>
|
||||
|
||||
</properties>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<artifactId>launchers-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -46,4 +46,4 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.tencent.supersonic.config;
|
||||
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.LaxRedirectStrategy;
|
||||
|
||||
|
||||
import org.apache.hc.client5.http.impl.LaxRedirectStrategy;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
@@ -16,14 +18,19 @@ public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
|
||||
// HttpClient 5 较新版本才会有LaxRedirectStrategy, 所以我重新定义了
|
||||
CloseableHttpClient httpClient =
|
||||
// HttpClientBuilder.create().setRedirectStrategy(new DefaultRedirectStrategy()) //
|
||||
// 使用宽松重定向策略
|
||||
HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()) // 使用宽松重定向策略
|
||||
.build();
|
||||
|
||||
HttpComponentsClientHttpRequestFactory httpRequestFactory =
|
||||
new HttpComponentsClientHttpRequestFactory();
|
||||
new HttpComponentsClientHttpRequestFactory(httpClient);
|
||||
httpRequestFactory.setConnectionRequestTimeout(2000);
|
||||
httpRequestFactory.setConnectTimeout(10000);
|
||||
httpRequestFactory.setReadTimeout(7200000);
|
||||
HttpClient httpClient =
|
||||
HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build();
|
||||
httpRequestFactory.setHttpClient(httpClient);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
|
||||
restTemplate.getMessageConverters().set(1,
|
||||
new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
||||
|
||||
@@ -1,18 +1,43 @@
|
||||
package com.tencent.supersonic.web;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.boot.web.server.ErrorPage;
|
||||
import org.springframework.boot.web.server.ErrorPageRegistrar;
|
||||
import org.springframework.boot.web.server.ErrorPageRegistry;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
|
||||
/** error page config */
|
||||
@Component
|
||||
public class ErrorPageConfig implements ErrorPageRegistrar {
|
||||
public class ErrorPageConfig implements ErrorPageRegistrar, HandlerExceptionResolver, Ordered {
|
||||
|
||||
@Override
|
||||
public void registerErrorPages(ErrorPageRegistry registry) {
|
||||
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/webapp/index.html");
|
||||
registry.addErrorPages(error404Page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) {
|
||||
if (handler instanceof ResourceHttpRequestHandler
|
||||
&& ex instanceof NoResourceFoundException) {
|
||||
ModelAndView modelAndView = new ModelAndView("/webapp/index.html");
|
||||
response.setStatus(HttpStatus.OK.value());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,20 @@ package com.tencent.supersonic.web;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/webapp/**").addResourceLocations("classpath:/webapp/");
|
||||
|
||||
registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/webapp/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/").setViewName("forward:webapp/index.html");
|
||||
registry.addViewController("/").setViewName("forward:/webapp/index.html");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<artifactId>launchers-standalone</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<start-class>com.tencent.supersonic.StandaloneLauncher</start-class>
|
||||
</properties>
|
||||
<dependencies>
|
||||
@@ -121,6 +121,11 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-properties-migrator</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ CREATE TABLE IF NOT EXISTS `company` (
|
||||
`company_established_time` varchar(20) NOT NULL ,
|
||||
`founder` varchar(20) NOT NULL ,
|
||||
`ceo` varchar(20) NOT NULL ,
|
||||
`annual_turnover` bigint(15) ,
|
||||
`employee_count` int(7) ,
|
||||
`annual_turnover` bigint ,
|
||||
`employee_count` int ,
|
||||
PRIMARY KEY (`company_id`)
|
||||
);
|
||||
|
||||
@@ -61,15 +61,15 @@ CREATE TABLE IF NOT EXISTS `brand` (
|
||||
`brand_established_time` varchar(20) NOT NULL ,
|
||||
`company_id` varchar(50) NOT NULL ,
|
||||
`legal_representative` varchar(20) NOT NULL ,
|
||||
`registered_capital` bigint(15) ,
|
||||
`registered_capital` bigint ,
|
||||
PRIMARY KEY (`brand_id`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `brand_revenue` (
|
||||
`year_time` varchar(10) NOT NULL ,
|
||||
`brand_id` varchar(50) NOT NULL ,
|
||||
`revenue` bigint(15) NOT NULL,
|
||||
`profit` bigint(15) NOT NULL ,
|
||||
`revenue` bigint NOT NULL,
|
||||
`profit` bigint NOT NULL ,
|
||||
`revenue_growth_year_on_year` double NOT NULL ,
|
||||
`profit_growth_year_on_year` double NOT NULL
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat_query`
|
||||
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`query_text` mediumtext,
|
||||
`user_name` varchar(150) DEFAULT NULL COMMENT '',
|
||||
`query_state` int(1) DEFAULT NULL,
|
||||
`query_state` int DEFAULT NULL,
|
||||
`chat_id` BIGINT NOT NULL , -- context chat id
|
||||
`query_result` mediumtext NOT NULL ,
|
||||
`score` int DEFAULT '0',
|
||||
@@ -61,7 +61,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat_statistics`
|
||||
`user_name` varchar(150) DEFAULT NULL COMMENT '',
|
||||
`query_text` varchar(200),
|
||||
`interface_name` varchar(100) DEFAULT NULL COMMENT '',
|
||||
`cost` INT(6) NOT NULL ,
|
||||
`cost` INT NOT NULL ,
|
||||
`type` INT NOT NULL ,
|
||||
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user