!7 换了几个较小的包。缩了下 server 大小
Merge pull request !7 from 西东/feature/1.6.5-solon
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>2.2.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>fun.asgc</groupId>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>2.2.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>fun.asgc</groupId>
|
||||
|
||||
@@ -26,21 +26,18 @@
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.1.24</version>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.29</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.7.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package fun.asgc.neutrino.core.db.dao;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import fun.asgc.neutrino.core.db.annotation.Column;
|
||||
import fun.asgc.neutrino.core.db.annotation.Id;
|
||||
import lombok.Data;
|
||||
@@ -29,6 +29,7 @@ import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.activation.DataSource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -39,12 +40,12 @@ import java.util.List;
|
||||
* @date: 2022/6/28
|
||||
*/
|
||||
public class DaoTest {
|
||||
private DruidDataSource dataSource;
|
||||
private HikariDataSource dataSource;
|
||||
private DBType dbType;
|
||||
|
||||
{
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf8");
|
||||
dataSource = new HikariDataSource();
|
||||
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf8");
|
||||
dataSource.setUsername("root");
|
||||
dataSource.setPassword("YWasgc@10520");
|
||||
dbType = DBType.MYSQL;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package fun.asgc.neutrino.core.db.mapper;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import fun.asgc.neutrino.core.annotation.Bean;
|
||||
import fun.asgc.neutrino.core.annotation.Component;
|
||||
import fun.asgc.neutrino.core.annotation.Order;
|
||||
@@ -38,8 +38,8 @@ public class Configuration {
|
||||
|
||||
@Bean
|
||||
public JdbcTemplate jdbcTemplate() {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf8");
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf8");
|
||||
dataSource.setUsername("root");
|
||||
dataSource.setPassword("YWasgc@10520");
|
||||
return new JdbcTemplate(dataSource);
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package fun.asgc.neutrino.core.db.template;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import fun.asgc.neutrino.core.db.annotation.Id;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -42,8 +42,8 @@ public class JdbcTemplateTestForMySql {
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
{
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf8");
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf8");
|
||||
dataSource.setUsername("root");
|
||||
dataSource.setPassword("YWasgc@10520");
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+3
-4
@@ -21,8 +21,7 @@
|
||||
*/
|
||||
package fun.asgc.neutrino.core.db.template;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import fun.asgc.neutrino.core.db.annotation.Id;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -41,9 +40,9 @@ public class JdbcTemplateTestForSqlite {
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
{
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
// dataSource.setUrl("jdbc:sqlite:" + JdbcTemplateTestForSqlite.class.getResource("/sqlite.db").getPath());
|
||||
dataSource.setUrl("jdbc:sqlite:../data.db");
|
||||
dataSource.setJdbcUrl("jdbc:sqlite:../data.db");
|
||||
dataSource.setDriverClassName("org.sqlite.JDBC");
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-lib</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>5.8.15</version>
|
||||
<version>${hutool.ver}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>fun.asgc.neutrino</groupId>-->
|
||||
|
||||
@@ -13,27 +13,22 @@
|
||||
|
||||
<artifactId>neutrino-proxy-server</artifactId>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-api</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>mybatis-plus-solon-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>mybatis-pagehelper-solon-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>activerecord-solon-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<!--orika orika-solon-plugin用户,server端没直接用,为何这里需要引入?-->
|
||||
<dependency>
|
||||
@@ -44,7 +39,7 @@
|
||||
<dependency>
|
||||
<groupId>fun.asgc</groupId>
|
||||
<artifactId>orika-solon-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>2.2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../_solon_plugin/orika-solon-plugin/pom.xml</systemPath>
|
||||
</dependency>
|
||||
@@ -52,7 +47,7 @@
|
||||
<dependency>
|
||||
<groupId>fun.asgc</groupId>
|
||||
<artifactId>job-solon-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>2.2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../_solon_plugin/job-solon-plugin/pom.xml</systemPath>
|
||||
</dependency>
|
||||
@@ -69,17 +64,14 @@
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.39.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.1.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.29</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package fun.asgc.neutrino.proxy.server;
|
||||
import fun.asgc.solon.extend.job.annotation.EnableJob;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Controller;
|
||||
import org.noear.solon.annotation.SolonMain;
|
||||
import org.noear.solon.web.cors.CrossFilter;
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ import org.noear.solon.web.cors.CrossFilter;
|
||||
* @date: 2022/6/16
|
||||
*/
|
||||
@EnableJob
|
||||
@Controller
|
||||
@SolonMain
|
||||
public class ProxyServer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+2
@@ -48,6 +48,7 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
|
||||
private static List<String> initDataTableNameList = Lists.newArrayList("user", "license", "port_pool", "port_mapping", "job_info");
|
||||
@Inject
|
||||
private DbConfig dbConfig;
|
||||
|
||||
private DbTypeEnum dbTypeEnum;
|
||||
|
||||
@Init
|
||||
@@ -91,6 +92,7 @@ public class DBInitialize implements EventListener<AppLoadEndEvent> {
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initDBData() throws Exception {
|
||||
|
||||
+11
-8
@@ -1,10 +1,10 @@
|
||||
package fun.asgc.neutrino.proxy.server.base.db;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder;
|
||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import fun.asgc.neutrino.proxy.server.constant.DbTypeEnum;
|
||||
import org.apache.ibatis.solon.annotation.Db;
|
||||
import org.noear.solon.annotation.Bean;
|
||||
@@ -31,14 +31,17 @@ public class DbConfiguration {
|
||||
dataSource.setJournalMode(SQLiteConfig.JournalMode.WAL.getValue());
|
||||
return dataSource;
|
||||
} else if (DbTypeEnum.MYSQL == dbTypeEnum) {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
dataSource.setDriverClassName(dbConfig.getDriverClass());
|
||||
dataSource.setUrl(dbConfig.getUrl());
|
||||
dataSource.setInitialSize(5);
|
||||
dataSource.setMinIdle(5);
|
||||
dataSource.setMaxActive(20);
|
||||
dataSource.setMaxWait(60000);
|
||||
dataSource.setPoolPreparedStatements(true);
|
||||
dataSource.setJdbcUrl(dbConfig.getUrl());
|
||||
dataSource.setMinimumIdle(5);
|
||||
dataSource.setMaximumPoolSize(20);
|
||||
dataSource.setMaxLifetime(60000);
|
||||
// dataSource.setInitialSize(5);
|
||||
// dataSource.setMinIdle(5);
|
||||
// dataSource.setMaxActive(20);
|
||||
// dataSource.setMaxWait(60000);
|
||||
// dataSource.setPoolPreparedStatements(true);
|
||||
dataSource.setUsername(dbConfig.getUsername());
|
||||
dataSource.setPassword(dbConfig.getPassword());
|
||||
return dataSource;
|
||||
|
||||
+15
-10
@@ -11,6 +11,7 @@ import org.noear.solon.annotation.Bean;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.AopContext;
|
||||
import org.noear.solon.core.bean.LifecycleBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,16 +21,19 @@ import java.util.List;
|
||||
* @date: 2022/10/8
|
||||
*/
|
||||
@Configuration
|
||||
public class ProxyConfiguration {
|
||||
@Bean
|
||||
public void dispatcher(@Inject AopContext aopContext) {
|
||||
aopContext.lifecycle(() -> {
|
||||
List<ProxyMessageHandler> list = aopContext.getBeansOfType(ProxyMessageHandler.class);
|
||||
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("消息调度器", list,
|
||||
proxyMessage -> ProxyDataTypeEnum.of((int)proxyMessage.getType()) == null ?
|
||||
null : ProxyDataTypeEnum.of((int)proxyMessage.getType()).getName());
|
||||
aopContext.wrapAndPut(Dispatcher.class, dispatcher);
|
||||
});
|
||||
public class ProxyConfiguration implements LifecycleBean {
|
||||
@Inject
|
||||
AopContext aopContext;
|
||||
|
||||
@Override
|
||||
public void start() throws Throwable {
|
||||
List<ProxyMessageHandler> list = aopContext.getBeansOfType(ProxyMessageHandler.class);
|
||||
|
||||
Dispatcher<ChannelHandlerContext, ProxyMessage> dispatcher = new DefaultDispatcher<>("消息调度器", list,
|
||||
proxyMessage -> ProxyDataTypeEnum.of((int)proxyMessage.getType()) == null ?
|
||||
null : ProxyDataTypeEnum.of((int)proxyMessage.getType()).getName());
|
||||
|
||||
aopContext.wrapAndPut(Dispatcher.class, dispatcher);
|
||||
}
|
||||
|
||||
@Bean("serverBossGroup")
|
||||
@@ -41,4 +45,5 @@ public class ProxyConfiguration {
|
||||
public NioEventLoopGroup serverWorkerGroup() {
|
||||
return new NioEventLoopGroup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -74,17 +74,20 @@ public class BaseAuthInterceptor implements RouterInterceptor {
|
||||
|
||||
if (result instanceof Throwable) {
|
||||
log.error("全局异常", (Throwable) result);
|
||||
|
||||
if (result instanceof ServiceException) {
|
||||
ServiceException exception = (ServiceException) result;
|
||||
return new ResponseBody<>()
|
||||
.setCode(exception.getCode())
|
||||
.setMsg(exception.getMsg());
|
||||
}
|
||||
|
||||
return new ResponseBody<>()
|
||||
.setCode(ExceptionConstant.SYSTEM_ERROR.getCode())
|
||||
.setMsg(ExceptionConstant.SYSTEM_ERROR.getMsg())
|
||||
.setStack(ExceptionUtils.getStackTrace((Throwable) result));
|
||||
}
|
||||
|
||||
return new ResponseBody<>()
|
||||
.setCode(0)
|
||||
.setData(result);
|
||||
|
||||
+3
-1
@@ -24,13 +24,15 @@ public class GlobalExceptionFilter implements Filter {
|
||||
chain.doFilter(ctx);
|
||||
} catch (Throwable e) {
|
||||
log.error("全局异常", e);
|
||||
|
||||
if (e instanceof ServiceException) {
|
||||
ServiceException serviceException = (ServiceException)e;
|
||||
ServiceException serviceException = (ServiceException) e;
|
||||
ctx.render(new ResponseBody<>()
|
||||
.setCode(serviceException.getCode())
|
||||
.setMsg(serviceException.getMsg()));
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.render(new ResponseBody<>()
|
||||
.setCode(ExceptionConstant.SYSTEM_ERROR.getCode())
|
||||
.setMsg(ExceptionConstant.SYSTEM_ERROR.getMsg())
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.2.2</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<groupId>fun.asgc.neutrino</groupId>
|
||||
<artifactId>neutrino-proxy</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
@@ -50,12 +57,12 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.0</version>
|
||||
<version>1.18.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.25</version>
|
||||
<version>1.33</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@@ -83,6 +90,21 @@
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.39.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.49</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>4.0.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user