Commit 459abe91 authored by yourName's avatar yourName

初始化数据融合计算中心工程

parent b520f376
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
This diff is collapsed.
package net.wanji.datacenter;
import com.wanji.common.framework.spring.ServiceBeanContext;
import lombok.SneakyThrows;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author mapabc5
*/
@SpringBootApplication(exclude = {FeignAutoConfiguration.class, DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class})
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableSwagger2
@EnableTransactionManagement
@EnableScheduling
@EnableAsync //启用异步任务
public class DataCeneterApplication implements ApplicationListener<ContextRefreshedEvent> {
public static void main(String[] args) {
//解决 es 和 spring 的 netty冲突
System.setProperty("es.set.netty.runtime.available.processors", "false");
SpringApplication.run(DataCeneterApplication.class);
}
//监听到上下文刷新事件,立即加载上下文到我们维护的ServiceBeanContext中;
// 可以保证在ApplicationRunner中通过ServiceBeanContext.getBean(XXXProvider.class); 获取bean成功
@SneakyThrows
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ServiceBeanContext.loadContext(contextRefreshedEvent.getApplicationContext());
}
}
package net.wanji.datacenter.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration
public class CrossDomain {
private CorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.setAllowCredentials(true);
return corsConfiguration;
}
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", buildConfig());
return new CorsFilter(source);
}
}
package net.wanji.datacenter.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().permitAll().and().logout().permitAll();//配置不需要登录验证
}
}
#!/bin/sh
#
# start datacenter restful
#
###EOF
prog=DataCeneterApplication
export JAVA_HOME=${JAVA_HOME}
pwd=$(cd `dirname $0`; pwd)
echo $pwd
export DEPLOY_PATH=${pwd%/*}
echo ${DEPLOY_PATH}
export DEBUG_PORT=6083
if [ ! -d $JAVA_HOME ];then
echo "please set right JAVA_HOME in this file"
exit 0
fi
if [ ! -d $DEPLOY_PATH ];then
echo "please set right DEPLOY_PATH in this file"
exit 0
fi
function usage(){
cat << EOF
Usage: startServer.sh --port <port> [options]
Options:
--help | -h Print usage information.
--port | -p Set java debug port, default value(5100).
EOF
exit $1
}
while [ $# -gt 0 ]; do
case "$1" in
-h|--help) usage 0 ;;
-p|--port) shift; DEBUG_PORT=$1 ;;
*) shift ;; # ignore
esac
shift
done
export JAVA_OPTIONS="-Xmx512m -Xms512m -XX:MetaspaceSize=256m"
export CLASSPATH=.:${CLASSPATH}:${DEPLOY_PATH}/resources:${DEPLOY_PATH}/lib/*
$JAVA_HOME/bin/java -cp ${CLASSPATH}:${DEPLOY_PATH}/lib/wj-datacenter-service-1.0.jar:. ${JAVA_OPTIONS} ${JAVA_DEBUG} com.wanji.nvrplayback.DataCeneterApplication $prog &
#!/bin/sh
#
# stop datacenter restful
#
###EOF
prog=DataCeneterApplication
pid=`ps -ef|grep $prog | grep java | grep -v grep|awk '{print $2}'`
if [ ! "$pid" ];then
echo "$prog is not running"
else
echo -e "stop $prog : $pid"
kill -9 $pid
fi
exit 0
spring:
application:
name: wj-datacenter-service
cloud:
nacos:
config:
server-addr: 10.102.1.182:8848
file-extension: yaml
group: wanji
namespace: wanji
username: nacos
password: nacos
\ No newline at end of file
spring:
application:
name: wj-datacenter-service
cloud:
nacos:
config:
server-addr: 172.17.0.1:8848
file-extension: yaml
group: wanji
namespace: wanji
username: nacos
password: nacos
\ No newline at end of file
spring:
application:
name: wj-datacenter-service
cloud:
nacos:
config:
server-addr: 192.168.2.78:8848
file-extension: yaml
group: wanji
namespace: wanji
username: nacos
password: nacos
\ No newline at end of file
spring:
application:
name: wj-datacenter-service
cloud:
nacos:
config:
server-addr: 10.102.1.182:8848
file-extension: yaml
group: wanji
namespace: wanji
username: nacos
password: nacos
\ No newline at end of file
spring:
profiles:
active: dev
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--这个Status用于设置log4j的内部输出,一般设为OFF,或者ERROR-->
<Configuration status="ERROR">
<!--日志存放目录以日志压缩存放目录-->
<Properties>
<Property name="LOG_HOME">/home/wj-platform/wj-datacenter-service/log</Property>
<Property name="fileGz">/home/wj-platform/wj-datacenter-service/log</Property>
</Properties>
<Appenders>
<!--控制台输出-->
<Console name="SYSOUT" target="SYSTEM_OUT">
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
<!-- 输出日志的格式 -->
<PatternLayout pattern="[Server-log4j2][%d{HH:mm:ss.SSS}][%-5level][%logger{2}]-%msg%n"/>
</Console>
<!--ERROR级别日志输出-->
<RollingRandomAccessFile name="ERRORFile"
fileName="${LOG_HOME}/server_ERROR.log"
filePattern="${LOG_HOME}/server_ERROR.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件,这里设置了20 -->
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
<!--ERROR级别日志输出-->
<RollingRandomAccessFile name="ERRORFile"
fileName="${LOG_HOME}/server_ERROR.log"
filePattern="${LOG_HOME}/server_ERROR.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
<!--ERRORING级别日志输出-->
<RollingRandomAccessFile name="ERRORFile"
fileName="${LOG_HOME}/server_ERRORing.log"
filePattern="${LOG_HOME}/server_ERRORing.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
<!--ERROR级别日志输出-->
<RollingRandomAccessFile name="ERRORFile"
fileName="${LOG_HOME}/server_ERROR.log"
filePattern="${LOG_HOME}/server_ERROR.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
</Appenders>
<!--然后定义logger,只有定义了logger并引入的appender,appender才会生效-->
<Loggers>
<!--过滤掉spring的一些无用的ERROR信息-->
<Root level="ERROR">
<AppenderRef ref="SYSOUT"/>
<AppenderRef ref="ERRORFile"/>
<AppenderRef ref="ERRORFile"/>
<AppenderRef ref="ERRORFile"/>
<AppenderRef ref="ERRORFile"/>
</Root>
<Logger name="com.tscloud" level="ERROR"/>
<Logger name="com.iov" level="ERROR"/>
<Logger name="com.alibaba" level="ERROR"/>
<Logger name="org.apache.ignite" level="ERROR"/>
<Logger name="org.eclipse.jetty.servlet.ServletHandler" level="ERROR"/>
<Logger name="com.ibatis" level="ERROR"/>
<Logger name="com.ibatis.common.jdbc.SimpleDataSource" level="ERROR"/>
<Logger name="com.ibatis.common.jdbc.ScriptRunner" level="ERROR"/>
<Logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="ERROR"/>
<Logger name="java.sql.Connection" level="ERROR"/>
<Logger name="java.sql.Statement" level="ERROR"/>
<Logger name="java.sql.PreparedStatement" level="ERROR"/>
<Logger name="org.apache.zookeeper" level="ERROR"/>
<Logger name="com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry" level="ERROR"/>
<Logger name="com.alibaba.dubbo.config.AbstractConfig" level="ERROR"/>
</Loggers>
</Configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!--这个Status用于设置log4j的内部输出,一般设为OFF,或者ERROR-->
<Configuration status="OFF">
<!--日志存放目录以日志压缩存放目录-->
<Properties>
<Property name="LOG_HOME">../log/wj-datacenter-service</Property>
<Property name="fileGz">../log/wj-datacenter-service</Property>
</Properties>
<Appenders>
<!--控制台输出-->
<Console name="SYSOUT" target="SYSTEM_OUT">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<!-- 输出日志的格式 -->
<PatternLayout pattern="[Server-log4j2][%d{HH:mm:ss.SSS}][%-5level][%logger{2}]-%msg%n"/>
</Console>
<!--DEBUG级别日志输出-->
<RollingRandomAccessFile name="DebugFile"
fileName="${LOG_HOME}/server_debug.log"
filePattern="${LOG_HOME}/server_debug.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件,这里设置了20 -->
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
<!--INFO级别日志输出-->
<RollingRandomAccessFile name="InfoFile"
fileName="${LOG_HOME}/server_info.log"
filePattern="${LOG_HOME}/server_info.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
<!--WARNING级别日志输出-->
<RollingRandomAccessFile name="WarnFile"
fileName="${LOG_HOME}/server_warning.log"
filePattern="${LOG_HOME}/server_warning.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
<!--ERROR级别日志输出-->
<RollingRandomAccessFile name="ErrorFile"
fileName="${LOG_HOME}/server_error.log"
filePattern="${LOG_HOME}/server_error.%d{yyyyMMdd}.log">
<Filters>
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1"/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>
</Appenders>
<!--然后定义logger,只有定义了logger并引入的appender,appender才会生效-->
<Loggers>
<!--过滤掉spring的一些无用的DEBUG信息-->
<Root level="Debug">
<AppenderRef ref="SYSOUT"/>
<AppenderRef ref="DebugFile"/>
<AppenderRef ref="InfoFile"/>
<AppenderRef ref="WarnFile"/>
<AppenderRef ref="ErrorFile"/>
</Root>
<Logger name="com.tscloud" level="info"/>
<Logger name="com.iov" level="info"/>
<Logger name="com.alibaba" level="info"/>
<Logger name="org.apache.ignite" level="info"/>
<Logger name="org.eclipse.jetty.servlet.ServletHandler" level="info"/>
<Logger name="com.smartbear.soapui" level="info"/>
<Logger name="com.eviware.soapui" level="info"/>
<Logger name="org.apache.xmlbeans" level="info"/>
<Logger name="com.ibatis" level="debug"/>
<Logger name="com.ibatis.common.jdbc.SimpleDataSource" level="debug"/>
<Logger name="com.ibatis.common.jdbc.ScriptRunner" level="debug"/>
<Logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="debug"/>
<Logger name="java.sql.Connection" level="debug"/>
<Logger name="java.sql.Statement" level="debug"/>
<Logger name="java.sql.PreparedStatement" level="debug"/>
<Logger name="org.apache.zookeeper" level="error"/>
<Logger name="com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry" level="error"/>
<Logger name="com.alibaba.dubbo.config.AbstractConfig" level="error"/>
</Loggers>
</Configuration>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment