Commit bed2616b authored by 李健华's avatar 李健华

初始化项目

parents
Pipeline #1303 failed with stages
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
#*.jar
*.rar
#*.tar
#*.zip
!.mvn/wrapper/maven-wrapper.jar
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
.db
.csv
.xlsx
.xls
# Eclipse generated files #
.classpath
.project
.settings/
.tomcatplugin
.#webclasspath
target/
work/
# Idea generated files #
*.iml
*.ipr
*.iws
.idea/
.svn/
logging.dir_IS*/
project.name_IS_*/
project.name_IS_*.log
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>servers</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>target/bin</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${project.package.name}.jar</source>
<outputDirectory>/</outputDirectory>
<destName>${project.package.name}.jar</destName>
</file>
<file>
<source>target/config/application-${spring.profiles.active}.properties</source>
<outputDirectory>/config</outputDirectory>
<destName>application.properties</destName>
</file>
<file>
<source>target/config/logback-spring.xml</source>
<outputDirectory>/config</outputDirectory>
<destName>logback-spring.xml</destName>
</file>
</files>
</assembly>
\ No newline at end of file
#!/bin/sh
JAVA="$JAVA_HOME/bin/java"
JAVAPS="$JAVA_HOME/bin/jps"
if $cygwin
then
KILL=/bin/kill
else
KILL=kill
fi
if readlink -f "$0" > /dev/null 2>&1
then
APP_BIN=$(readlink -f $0)
else
APP_BIN=$(pwd -P)
fi
#APP_HOME=${APP_BIN%'/bin'*}
APP_HOME=${APP_BIN%'/'*}
echo "[INFO]Terminate the server; home=$APP_HOME"
CPS=$(ps -e -opid,cmd | grep -i "^[0-9]* .*/java .*-Dapplication.home.dir=$APP_HOME .*${project.name}.*\.jar" | grep -v "grep" | head -n 1 | awk '{print $1}')
if [ -z "$CPS" ]; then
echo "[INFO]server is not running"
exit 1
else
PSID=${CPS%%" /"*}
if [ $PSID -eq 0 ]; then
echo "[ERROR]Not found PID"
exit 1
else
$KILL -15 $PSID
echo "[INFO]Stopped server; home=$APP_HOME; PID=$PSID"
exit 0
fi
fi
\ No newline at end of file
#!/bin/sh
if [ "$JAVA_HOME" != "" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=java
fi
echo "JAVA: "$JAVA
if readlink -f "$0" > /dev/null 2>&1
then
BIN_PATH=$(readlink -f $0)
else
BIN_PATH=$(pwd -P)
fi
#APP_HOME=${BIN_PATH%"/bin"*}
APP_HOME=${BIN_PATH%"/"*}
echo "APP_HOME: "$APP_HOME
APP_JAR=$(find "$APP_HOME" -maxdepth 1 -name "${project.name}*\.jar" | head -n 1)
if [ -z "$APP_JAR" ]; then
echo "[ERROR]Not found main jar file"
exit 1
fi
echo "APP_JAR: "$APP_JAR
echo "[INFO]Start the server; home=$APP_HOME"
CPS=$(ps -e -opid,cmd | grep -i "^[0-9]* .*/java .*-Dapplication.home.dir=$APP_HOME .*${project.name}.*\.jar" | grep -v "grep" | head -n 1 | awk '{print $1}')
if [ -n "$CRACKPS" ]; then
echo "[ERROR]Server is running;"
exit 1
else
JAVAOPTS="-Xms512m -Xmx1024m -Xmn256m -Xss1024k"
APPOPTS="-Dfile.encoding=UTF-8 -Dapplication.home.dir=$APP_HOME -Dlogging.config=$APP_HOME/config/logback-spring.xml"
echo "[INFO]Application options: $APPOPTS"
$JAVA $JAVAOPTS $APPOPTS "-jar" $APP_JAR "--spring.config.file=$APP_HOME/config/application.properties" 2>&1 >/dev/null &
#echo $JAVA $JAVAOPTS "-jar" $APP_JAR
exit 0
fi
\ No newline at end of file
CREATE TABLE `optimistic` (
`DESC_TEXT` varchar(400) DEFAULT NULL COMMENT '描述',
`CREATED_BY` varchar(72) NOT NULL COMMENT '创建用户',
`CREATED_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`MODIFIED_BY` varchar(72) NOT NULL COMMENT '更新用户',
`MODIFIED_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`MODIFIED_NO` int(8) NOT NULL DEFAULT '0' COMMENT '更新次数',
`PARTITION_KEY` smallint(4) NOT NULL COMMENT '分区键',
`EXTENDED_FIELD1` varchar(4) DEFAULT NULL,
`EXTENDED_FIELD2` varchar(4) DEFAULT NULL,
`EXTENDED_FIELD3` varchar(4) DEFAULT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table optimistic add `DESC_TEXT` varchar(400) DEFAULT NULL COMMENT '描述';
alter table optimistic add `CREATED_BY` varchar(72) NOT NULL COMMENT '创建用户';
alter table optimistic add `CREATED_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间';
alter table optimistic add `MODIFIED_BY` varchar(72) NOT NULL COMMENT '更新用户';
alter table optimistic add `MODIFIED_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间';
alter table optimistic add `MODIFIED_NO` int(8) NOT NULL DEFAULT '0' COMMENT '更新次数';
alter table optimistic add `PARTITION_KEY` smallint(4) NOT NULL COMMENT '分区键';
alter table optimistic add `EXTENDED_FIELD1` varchar(4) DEFAULT NULL;
alter table optimistic add `EXTENDED_FIELD2` varchar(4) DEFAULT NUL;
alter table optimistic add `EXTENDED_FIELD3` varchar(4) DEFAULT NULL;
\ No newline at end of file
package org.example;
import cn.quant.spring.util.IdentitySequencer;
import cn.quant.spring.util.ServerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* <p><b>Application VM Option:</b><br/>
* <code>--spring.config.file=${project.build.directory}/target/config/application-dev.properties </code><br/>
* <code>-Dlogging.config=${project.build.directory}/target/config/logback-spring.xml</code></p>
* <p><b>Enable Dubbo Annotation: </b><br/>
* <code>@org.springframework.context.annotation.ImportResource(locations = {"classpath:application-dubbo.xml"})</code></p>
*/
@ComponentScan
@SpringBootApplication
@EnableAutoConfiguration(exclude = {
// DataSourceAutoConfiguration.class,
// DataSourceTransactionManagerAutoConfiguration.class,
// HibernateJpaAutoConfiguration.class
})
@PropertySource(value = {"classpath:config/bootstrap.yml"
, "classpath:config/application.yml"
, "file:${spring.config.file}"})
public class ServerApplication {
@Inject
private ApplicationContext context;
@PostConstruct
private void init() throws Exception {
Environment environment = context.getEnvironment();
IdentitySequencer sequencer = context.getBean(IdentitySequencer.class);
Logger logger = LoggerFactory.getLogger(ServerApplication.class);
logger.info("\n---------------------------------------------------------------------\n" +
"\tWorker Id : {}\n" +
"\tServer IP : {}\n" +
"\tConfig File : {}\n" +
"\tSpring Profiles : {}\n" +
"\tRuntime : {}\n" +
"\n---------------------------------------------------------------------\n"
, sequencer.workerId()
, ServerUtils.getHostAddress()
, environment.getProperty("spring.config.file")
, environment.getActiveProfiles()
, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
}
public static void main(String[] args) {
SpringApplication application = new SpringApplication(ServerApplication.class);
ConfigurableApplicationContext context = application.run(args);
}
}
\ No newline at end of file
package org.example;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* Created by hechao included 2020/1/22.
*/
public class ServerServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ServerApplication.class);
}
}
\ No newline at end of file
package org.example.config;
import org.example.support.AuditorAwareHandler;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* <p><b>Enable Mybatis Annotation:</b><br/>
* <code>@org.mybatis.spring.annotation.MapperScan("org.example.mybatis.mapper")</code></p>
* <p><b>Enable JPA Annotation:</b><br/>
* <code>@EntityScan("org.example.jpa.entity")</code><br/>
* <code>@org.springframework.data.jpa.repository.config.EnableJpaRepositories("org.example.jpa.repository")</code></p>
* <p><b>Enable Auditor Aware Annotation:</b><br/>
* <code>@org.springframework.data.jpa.repository.config.EnableJpaAuditing(auditorAwareRef = "auditorAwareHandler")<br/>
* see {@link AuditorAwareHandler}</code>
* </p>
* @see cn.quant.spring.convert.LocalDateNumberConverter
* @see cn.quant.spring.convert.LocalDateTimeNumberConverter
* @see cn.quant.spring.convert.LocalTimeNumberConverter
*/
@Configuration
@EnableTransactionManagement
@EntityScan("org.example.jpa.entity")
@EnableJpaRepositories("org.example.jpa.repository")
@EnableJpaAuditing(auditorAwareRef = "auditorAwareHandler")
public class DatabaseConfiguration {
// TODO:Hibernate Jackson Support
@Bean
public Hibernate5Module hibernate5Module() {
return new Hibernate5Module();
}
}
\ No newline at end of file
package org.example.config;
import java.io.IOException;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
import org.kie.api.builder.ReleaseId;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.internal.io.ResourceFactory;
import org.kie.spring.KModuleBeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
/**
* 配置Drools的服务类,方便在Rest接口中调用。 该类负责加载具体的drl规则文件, 不再需要kmodule.xml配置文件了。
*/
@Configuration
public class DroolsAutoConfiguration {
private static final String RULES_PATH = "rules/";
@Bean
@ConditionalOnMissingBean(KieFileSystem.class)
public KieFileSystem kieFileSystem() throws IOException {
KieFileSystem kieFileSystem = getKieServices().newKieFileSystem();
for (Resource file : getRuleFiles()) {
System.out.println("---");
System.out.println(ResourceFactory.newClassPathResource(RULES_PATH + file.getFilename(), "UTF-8"));
System.out.println("---");
kieFileSystem.write(ResourceFactory.newClassPathResource(RULES_PATH + file.getFilename(), "UTF-8"));
}
return kieFileSystem;
}
private Resource[] getRuleFiles() throws IOException {
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
return resourcePatternResolver.getResources("classpath*:" + RULES_PATH + "**/*.*");
}
@Bean
@ConditionalOnMissingBean(KieContainer.class)
public KieContainer kieContainer() throws IOException {
final KieRepository kieRepository = getKieServices().getRepository();
kieRepository.addKieModule(new KieModule() {
@Override
public ReleaseId getReleaseId() {
return kieRepository.getDefaultReleaseId();
}
});
KieBuilder kieBuilder = getKieServices().newKieBuilder(kieFileSystem());
kieBuilder.buildAll();
return getKieServices().newKieContainer(kieRepository.getDefaultReleaseId());
}
private KieServices getKieServices() {
return KieServices.Factory.get();
}
@Bean
@ConditionalOnMissingBean(KieBase.class)
public KieBase kieBase() throws IOException {
return kieContainer().getKieBase();
}
// 不能反复被使用,释放资源后需要重新获取。
// @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@Bean
@ConditionalOnMissingBean(KieSession.class)
public KieSession kieSession() throws IOException {
return kieContainer().newKieSession();
}
@Bean
@ConditionalOnMissingBean(KModuleBeanFactoryPostProcessor.class)
public KModuleBeanFactoryPostProcessor kiePostProcessor() {
return new KModuleBeanFactoryPostProcessor();
}
}
package org.example.config;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.ZonedDateTimeSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.List;
/**
* Created by hechao on 2018/6/28.
*/
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
private MappingJackson2HttpMessageConverter messageConverter;
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(messageConverter);
}
@Bean
public MappingJackson2HttpMessageConverter httpMessageConverter() {
messageConverter = new MappingJackson2HttpMessageConverter();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
simpleModule.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE);
simpleModule.addDeserializer(LocalDateTime.class, LocalDateTimeDeserializer.INSTANCE);
simpleModule.addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE);
simpleModule.addDeserializer(LocalDate.class, LocalDateDeserializer.INSTANCE);
simpleModule.addSerializer(ZonedDateTime.class, ZonedDateTimeSerializer.INSTANCE);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(simpleModule);
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
messageConverter.setObjectMapper(objectMapper);
return messageConverter;
}
}
/**
* application configuration
*/
package org.example.config;
package org.example.drools;
import org.drools.core.definitions.rule.impl.RuleImpl;
import org.example.mybatis.entity.Person;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 触发Person相关的规则后的处理类
*
* @author yuwen
*
*/
public class PersonRuleAction {
private static Logger LOG = LoggerFactory.getLogger(PersonRuleAction.class);
// 目前只实现记录日志功能
public static void doParse(Person person, RuleImpl rule) {
LOG.debug("{} is matched Rule[{}]!", person, rule.getName());
}
}
\ No newline at end of file
package org.example.dubbo.facade;
/**
* Created by hechao on 2020/2/11.
*/
public interface TestDubboServiceFacade {
void test(TestRequest request);
}
\ No newline at end of file
package org.example.dubbo.facade;
import java.io.Serializable;
/**
* Created by hechao on 2020/2/11.
*/
public class TestRequest implements Serializable{
private static final long serialVersionUID = 888372588201987618L;
private String attachment;
public String getAttachment() {
return attachment;
}
public void setAttachment(String attachment) {
this.attachment = attachment;
}
@Override
public String toString() {
return "TestRequest{" +
"attachment='" + attachment + '\'' +
'}';
}
}
/**
* dubbo facade interface and dto
*/
package org.example.dubbo.facade;
package org.example.dubbo.service;
import org.example.dubbo.facade.TestDubboServiceFacade;
import org.example.dubbo.facade.TestRequest;
/**
* Created by hechao on 2020/2/11.
*/
public class TestDubboServiceImpl implements TestDubboServiceFacade {
@Override
public void test(TestRequest request) {
System.out.println(request);
}
}
\ No newline at end of file
/**
* dubbo service
*/
package org.example.dubbo.service;
package org.example.http;
import java.io.Serializable;
/**
* Created by hechao on 2020/2/17.
*/
public class UserRequestData implements Serializable {
private static final long serialVersionUID = -4788059004517183253L;
private String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
/**
* application controller dto
*/
package org.example.http;
package org.example.jpa.entity;
import org.example.support.AuditorAwareHandler;
import cn.quant.spring.data.jpa.entity.OptimisticEntity;
import cn.quant.spring.data.jpa.entity.PartitionEntity;
import org.hibernate.envers.Audited;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
/**
* <p><b>Enable Audited Annotation:</b><br/>
* <code>@org.hibernate.envers.Audited</code><br/>
* <code>@javax.persistence.EntityListeners(AuditingEntityListener.class)</code><br/>
* <code>@javax.persistence.MappedSuperclass</code><br/>
* </p>
* Created by hechao on 2020/2/13.
* @see AuditorAwareHandler
*/
@Audited
@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public abstract class AuditedEntity extends PartitionEntity implements Serializable {
private static final long serialVersionUID = 7857933536111031118L;
}
\ No newline at end of file
package org.example.jpa.entity;
import cn.quant.spring.util.StringUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* Created by hechao on 2020/2/13.
*/
@Entity
@Table(name = "user")
public class UserEntity extends AuditedEntity implements Serializable {
private static final long serialVersionUID = 4871312362433000454L;
@Id
@Column(name = "USER_ID", nullable = false, updatable = false)
private Long userId;
@Column(name = "USER_NAME", nullable = false, length = 36)
private String userName;
@Column(name = "DATE", nullable = true, length = 8)
private LocalDate date;
@Column(name = "DATE_TIME", nullable = true, length = 19)
private LocalDateTime dateTime;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public LocalDate getDate() {
return date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public LocalDateTime getDateTime() {
return dateTime;
}
public void setDateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserEntity that = (UserEntity) o;
return Objects.equals(userId, that.userId);
}
@Override
public int hashCode() {
return Objects.hash(userId);
}
@Override
public String persistenceKey() {
return StringUtils.toDelimitedString(UserEntity.class.getSimpleName(), userId);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("UserEntity{");
sb.append("userId=").append(userId);
sb.append(", userName='").append(userName).append('\'');
sb.append(", date=").append(date);
sb.append(", dateTime=").append(dateTime);
sb.append(',').append(super.toString());
sb.append('}');
return sb.toString();
}
public UserEntity userId(Long userId) {
this.userId = userId;
return this;
}
public UserEntity userName(String userName) {
this.userName = userName;
return this;
}
public UserEntity date(LocalDate date) {
this.date = date;
return this;
}
public UserEntity dateTime(LocalDateTime dateTime) {
this.dateTime = dateTime;
return this;
}
}
/**
* jpa entity
*/
package org.example.jpa.entity;
package org.example.jpa.repository;
import org.example.jpa.entity.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* Created by hechao on 2020/2/17.
*/
@Repository
public interface UserRepository extends JpaRepository<UserEntity, Long> {
}
\ No newline at end of file
/**
* jpa repository
*/
package org.example.jpa.repository;
package org.example.jpa.support;
import cn.quant.spring.convert.LocalDateNumberConverter;
import javax.persistence.Converter;
/**
* <p><b>Enable Date To Number Annotation:</b><br/>
* <code>@javax.persistence.Converter(autoApply = true).</code></p>
* Created by hechao included 2020/2/28.
*/
@Converter(autoApply = true)
public class JpaLocalDateNumberConverter extends LocalDateNumberConverter {
public JpaLocalDateNumberConverter() {
}
}
package org.example.jpa.support;
import cn.quant.spring.convert.LocalDateTimeNumberConverter;
import javax.persistence.Converter;
/**
* <p><b>Enable Date To Number Annotation:</b><br/>
* <code>@javax.persistence.Converter(autoApply = true).</code></p>
* Created by hechao included 2020/2/28.
*/
@Converter(autoApply = true)
public class JpaLocalDateTimeNumberConverter extends LocalDateTimeNumberConverter {
public JpaLocalDateTimeNumberConverter() {
}
}
package org.example.jpa.support;
import cn.quant.spring.convert.LocalTimeNumberConverter;
import javax.persistence.Converter;
/**
* <p><b>Enable Date To Number Annotation:</b><br/>
* <code>@javax.persistence.Converter(autoApply = true).</code></p>
* Created by hechao included 2020/2/28.
*/
@Converter(autoApply = true)
public class JpaLocalTimeNumberConverter extends LocalTimeNumberConverter {
public JpaLocalTimeNumberConverter() {
}
}
package org.example.mybatis.entity;
public class DepartmentsEntity {
private String deptNo;
private String deptName;
public String getDeptNo() {
return deptNo;
}
public void setDeptNo(String deptNo) {
this.deptNo = deptNo;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
}
\ No newline at end of file
package org.example.mybatis.entity;
/**
* Created with IntelliJ IDEA.
*
* @author: Li JianHua
* @Date: 2021/9/17
* @Time: 18:16
* Description: No Description
*/
public class Person {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
package org.example.mybatis.mapper;
import org.example.mybatis.entity.DepartmentsEntity;
public interface DepartmentsMapper {
int deleteByPrimaryKey(String deptNo);
int insert(DepartmentsEntity record);
int insertSelective(DepartmentsEntity record);
DepartmentsEntity selectByPrimaryKey(String deptNo);
int updateByPrimaryKeySelective(DepartmentsEntity record);
int updateByPrimaryKey(DepartmentsEntity record);
}
\ No newline at end of file
/**
* mybatis mapper, entity
*/
package org.example.mybatis;
package org.example.rest;
import org.example.http.UserRequestData;
import org.example.jpa.entity.UserEntity;
import org.example.service.JpaService;
import cn.quant.spring.ExceptionEnum;
import cn.quant.spring.ServerRuntimeException;
import cn.quant.spring.rest.AbstractController;
import cn.quant.spring.web.annotation.JsonpMapping;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.Map;
/**
* Created by hechao on 2020/2/12.
*/
@RestController
@RequestMapping("/rest")
public class JpaController extends AbstractController {
// /*
//TODO:Jpa Service
@Inject
private JpaService jpaService;
@ResponseBody
@PostMapping("jpa/findOne")
public ResponseEntity findOne() {
UserEntity userEntity = jpaService.findOne(1L);
return ResponseEntity.ok().body(userEntity);
}
@ResponseBody
@PostMapping("jpa/save")
public ResponseEntity save() {
UserEntity userEntity = jpaService.save(new UserRequestData());
return succeed(userEntity);
}
// */
// /*
//TODO:Jsonp Request
@ResponseBody
@RequestMapping("jsonp")
@JsonpMapping
public ResponseEntity jsonp() {
try {
Map<String, String> map = new HashMap<String, String>(){{
put("name","test");
}};
return succeed(map);
}finally {
// new Integer(null);
throw new ServerRuntimeException(ExceptionEnum.SQL_UNAUTHORIZED);
// ;
}
}
// */
}
package org.example.rest;
import cn.quant.spring.rest.AbstractController;
import org.springframework.web.bind.annotation.*;
/**
* Created by hechao on 2020/2/12.
*/
@RestController
@RequestMapping("/rest")
public class MybatisController extends AbstractController {
/*
//Mybatis Service
@Inject
private MybatisService mybatisService;
@ResponseBody
@PostMapping("mybatis/get")
public ResponseEntity get(){
DepartmentsEntity entity = mybatisService.get();
return ResponseEntity.ok().body(entity);
}
*/
}
package org.example.rest;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.drools.core.impl.InternalKnowledgeBase;
import org.drools.core.impl.KnowledgeBaseFactory;
import org.example.mybatis.entity.Person;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("rule/person")
public class PersonRuleController {
@Autowired
private KieContainer kieContainer;
@PostMapping("one")
public void fireAllRules4One(@RequestBody Person person) {
KieSession kSession = kieContainer.newKieSession();
System.out.println(person);
try {
StringBuilder result = new StringBuilder();
/*package部分*/
result.append("package rule;\r\n");
result.append("\r\n");
/*导包部分*/
result.append("import java.util.List;\r\n");
result.append("\r\n");
/*规则申明部分*/
result.append("rule \"32353242\"\r\n");
/*规则属性部分*/
/*规则条件部分*/
result.append("\twhen\r\n");
result.append("\t\teval(true)\r\n");
/*规则结果部分*/
result.append("\tthen\r\n");
result.append("\t\tSystem.out.println(\"动态加载的规则被触发了\");\r\n");
/*规则结束*/
result.append("end\r\n");
StringBuilder result1 = new StringBuilder();
/*package部分*/
result1.append("package rule;\r\n");
result1.append("\r\n");
/*导包部分*/
result1.append("import java.util.List;\r\n");
result1.append("\r\n");
/*规则申明部分*/
result1.append("rule \"323532423333\"\r\n");
/*规则属性部分*/
/*规则条件部分*/
result1.append("\twhen\r\n");
result1.append("\t\teval(true)\r\n");
/*规则结果部分*/
result1.append("\tthen\r\n");
result1.append("\t\tSystem.out.println(\"动态加载的规则被触发了2\");\r\n");
/*规则结束*/
result1.append("end\r\n");
kSession.insert(person);
List<String> resultList = new ArrayList<>();
resultList.add(result.toString());
resultList.add(result1.toString());
getKieSessionFromDrl(resultList);
int rulesFired = kSession.fireAllRules();
System.out.println(rulesFired);
} catch (Exception e) {
} finally {
kSession.dispose();
}
}
@PostMapping("list")
public void fireAllRules4List(@RequestBody List<Person> persons) {
KieSession kSession = kieContainer.newKieSession();
try {
for (Person person : persons) {
kSession.insert(person);
}
kSession.fireAllRules();
} finally {
kSession.dispose();
}
}
public Date addDays(Date date, int addDays) {
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(date);
rightNow.add(Calendar.DATE, addDays);
return rightNow.getTime();
}
public static String dateFormat(Date date) {
try {
SimpleDateFormat DateFormat = new SimpleDateFormat("yyyy-MM-dd");
return DateFormat.format(date);
} catch (Exception e) {
System.out.println("123");
}
return "";
}
/**
* 由从数据库里面读出的drl构建KieSession
* @param drl
* @return
* @throws UnsupportedEncodingException
*/
public static KieSession getKieSessionFromDrl(List<String> drlList) throws UnsupportedEncodingException {
KieSession tempKieSession = null;
KnowledgeBuilder kb = KnowledgeBuilderFactory.newKnowledgeBuilder();
for (String drl : drlList) {
kb.add(ResourceFactory.newByteArrayResource(drl.getBytes("utf-8")), ResourceType.DRL);
}
if (kb.hasErrors()) {
String errorMessage = kb.getErrors().toString();
System.out.println("规则语法异常---\n"+errorMessage);
return null;
}
InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addPackages(kb.getKnowledgePackages());
tempKieSession = kBase.newKieSession();
tempKieSession.fireAllRules();
tempKieSession.dispose();
return tempKieSession;
}
}
\ No newline at end of file
/**
* application controller
*/
package org.example.rest;
package org.example.service;
import org.example.jpa.entity.UserEntity;
import org.example.jpa.repository.UserRepository;
import org.example.http.UserRequestData;
import cn.quant.spring.util.IdentitySequencer;
import cn.quant.spring.util.RandomSequencer;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* Created by hechao on 2020/2/17.
*/
@Service
public class JpaService {
@Inject
private UserRepository userRepository;
@Inject
private IdentitySequencer identitySequencer;
public UserEntity findOne(Long id){
return userRepository.findById(id).orElse(null);
}
public UserEntity save(UserRequestData request){
UserEntity userEntity = new UserEntity()
.userId(identitySequencer.nextId())
.userName(request.getUserName())
.date(LocalDate.now())
.dateTime(LocalDateTime.now());
userEntity.setPartitionKey(RandomSequencer.next(6, 2, 1000));
return userRepository.save(userEntity);
}
}
package org.example.service;
import org.springframework.stereotype.Service;
/**
* <p>Enable Mybatis Service Annotation:<br/>
* <code>@Service</code></p>
*
* Created by hechao on 2020/2/12.
*/
@Service
public class MybatisService {
/*
//Mybatis Mapper
@Inject
private DepartmentsMapper departmentsEntityMapper;
public DepartmentsEntity get(){
DepartmentsEntity entity = departmentsEntityMapper.selectByPrimaryKey("d009");
return entity;
}
*/
}
/**
* application service
*/
package org.example.service;
package org.example.support;
import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;
import java.util.Optional;
/**
* <p><b>Enable Auditor Aware:</b><br/>
* <code>@org.springframework.stereotype.Component("auditorAwareHandler")</code></p>
* Created by hechao included 2017/9/15.
* @see org.example.jpa.entity
*/
@Component("auditorAwareHandler")
public class AuditorAwareHandler implements AuditorAware<String> {
@Override
public Optional<String> getCurrentAuditor() {
return Optional.of("SYS");
}
}
\ No newline at end of file
package org.example.support;
import cn.quant.spring.ExceptionEnum;
import cn.quant.spring.ServerRuntimeException;
import cn.quant.spring.context.ContextLoader;
import cn.quant.spring.context.ServerApplicationContext;
import cn.quant.spring.http.HttpResponseData;
import cn.quant.spring.web.annotation.JsonpMapping;
import cn.quant.spring.web.support.JsonpResponseAdvice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;
/**
* <p><b>Enable Exception Advice Annotation:</b><br/>
* <code>@org.springframework.web.bind.annotation.RestControllerAdvice</code>
* </p>
* @date 2018-04-09 11:01
**/
//@RestControllerAdvice
public class ExceptionAdvice {
private static final Logger log = LoggerFactory.getLogger(ExceptionAdvice.class);
@ExceptionHandler(value = Exception.class)
@ResponseBody
public HttpResponseData handlerException(HttpServletRequest request, Exception e) {
log.error("Exception url:{}, error:{}", request.getRequestURI(), e);
String message = e.getMessage();
HttpResponseData responseData = new HttpResponseData(e);
if ((message == null) && ServerRuntimeException.class.isInstance(e)) {
ServerRuntimeException exception = (ServerRuntimeException) e;
ExceptionEnum type = exception.getType();
if (type != null) {
ServerApplicationContext applicationContext = ContextLoader.getCurrentApplicationContext();
message = applicationContext.getMessage(type.MESSAGE_CODE);
responseData.setMessage(message);
responseData.setStatus(type.ERROR_CODE);
}
}
return responseData;
}
}
\ No newline at end of file
package org.example.support;
import cn.quant.spring.web.annotation.JsonpMapping;
import cn.quant.spring.web.support.JsonpResponseAdvice;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* <p><b>Enable Jsonp Annotation:</b><br/>
* <code>@org.springframework.web.bind.annotation.RestControllerAdvice</code></p>
*
* Created by hechao included 2018/7/26.
* @see JsonpMapping
* @see RestControllerAdvice
* @see JsonpResponseAdvice
*/
//@RestControllerAdvice
public class HttpJsonpResponseAdvice extends JsonpResponseAdvice {
}
\ No newline at end of file
/**
* <p>Convert Entity Attribute:<br/>
* <code>annotation {@link javax.persistence.Converter}, interface {@link javax.persistence.AttributeConverter}.</code></P>
* <p>Inject Auditor Aware:<br/>
* <code>annotation {@link org.springframework.stereotype.Component}, interface {@link org.springframework.data.domain.AuditorAware}.</code></P>
*
*/
package org.example.support;
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<RollingFile name="RuleResultFile"
fileName="rule_result.log"
filePattern="rule_result-%i.log">
<PatternLayout
pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level [%l] - %msg%n" />
<Policies>
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>
<DefaultRolloverStrategy max="10" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.example.drools" level="DEBUG"
additivity="true">
<AppenderRef ref="RuleResultFile" />
</Logger>
<Root level="INFO">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
debug=true
#Spring
spring.profiles.active=dev
spring.application.name=Application
#Devtool
spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true
#Server
server.port=8089
server.servlet.context-path=/
#quant
quant.server.number=1
quant.server.sequencer.operator=TWEPOCH_PLUS
quant.server.sequencer.sequence-bits=8
#Database
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/users_center?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.hikari.minimum-idle=1
spring.datasource.hikari.maximum-pool-size=3
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.prepStmtCacheSize=250
spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048
spring.datasource.hikari.data-source-properties.useServerPrepStmts=true
#JPA
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.database=MYSQL
#Dubbo
dubbo.application.name=Application
dubbo.registry.address=zookeeper://172.17.15.101:3180?backup=172.17.15.102:3180,172.17.15.103:3180
dubbo.protocol.name=dubbo
dubbo.protocol.port=28080
TestDubboServiceFacade.version=1.0.0
TestDubboServiceFacade.timeout=30000
#Mybatis
#mybatis.mapper-locations=classpath:mapping/*.xml
#mybatis.type-aliases-package=org.example.mybatis
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="${dubbo.application.name}"/>
<dubbo:registry address="${dubbo.registry.address}"/>
<dubbo:protocol name="${dubbo.protocol.name}" port="${dubbo.protocol.port}" />
<bean id="testDubboService" class="org.example.dubbo.service.TestDubboServiceImpl"></bean>
<dubbo:service protocol="dubbo" interface="org.example.dubbo.facade.TestDubboServiceFacade"
ref="testDubboService"
version="${org.example.dubbo.facade.TestDubboServiceFacade.version}"
timeout="${org.example.dubbo.facade.TestDubboServiceFacade.timeout}" retries="0"/>
</beans>
debug=true
#Spring
spring.profiles.active=pre
spring.application.name=Application
#Devtool
spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true
#Server
server.port=8080
server.servlet.context-path=/
#quant
quant.server.number=1
quant.server.sequencer.operator=TWEPOCH_PLUS
quant.server.sequencer.sequence-bits=8
#Database
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/employees?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=111111
spring.datasource.hikari.minimum-idle=1
spring.datasource.hikari.maximum-pool-size=3
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.prepStmtCacheSize=250
spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048
spring.datasource.hikari.data-source-properties.useServerPrepStmts=true
#JPA
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.database=MYSQL
#Dubbo
dubbo.application.name=Application
dubbo.registry.address=zookeeper://172.17.15.101:3180?backup=172.17.15.102:3180,172.17.15.103:3180
dubbo.protocol.name=dubbo
dubbo.protocol.port=28080
TestDubboServiceFacade.version=1.0.0
TestDubboServiceFacade.timeout=30000
#Mybatis
#mybatis.mapper-locations=classpath:mapping/*.xml
#mybatis.type-aliases-package=org.example.mybatis
\ No newline at end of file
debug=true
#Spring
spring.profiles.active=pro
spring.application.name=Application
#Devtool
spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true
#Server
server.port=8080
server.servlet.context-path=/
#quant
quant.server.number=1
quant.server.sequencer.operator=TWEPOCH_PLUS
quant.server.sequencer.sequence-bits=8
#Database
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/employees?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=111111
spring.datasource.hikari.minimum-idle=1
spring.datasource.hikari.maximum-pool-size=3
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.prepStmtCacheSize=250
spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048
spring.datasource.hikari.data-source-properties.useServerPrepStmts=true
#JPA
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.database=MYSQL
#Dubbo
dubbo.application.name=Application
dubbo.registry.address=zookeeper://172.17.15.101:3180?backup=172.17.15.102:3180,172.17.15.103:3180
dubbo.protocol.name=dubbo
dubbo.protocol.port=28080
TestDubboServiceFacade.version=1.0.0
TestDubboServiceFacade.timeout=30000
#Mybatis
#mybatis.mapper-locations=classpath:mapping/*.xml
#mybatis.type-aliases-package=org.example.mybatis
\ No newline at end of file
debug=true
#Spring
spring.profiles.active=test
spring.application.name=Application
#Devtool
spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true
#Server
server.port=8080
server.servlet.context-path=/
#quant
quant.server.number=1
quant.server.sequencer.operator=TWEPOCH_PLUS
quant.server.sequencer.sequence-bits=8
#Database
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/employees?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=111111
spring.datasource.hikari.minimum-idle=1
spring.datasource.hikari.maximum-pool-size=3
spring.datasource.hikari.data-source-properties.cachePrepStmts=true
spring.datasource.hikari.data-source-properties.prepStmtCacheSize=250
spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048
spring.datasource.hikari.data-source-properties.useServerPrepStmts=true
#JPA
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.database=MYSQL
#Dubbo
dubbo.application.name=Application
dubbo.registry.address=zookeeper://172.17.15.101:3180?backup=172.17.15.102:3180,172.17.15.103:3180
dubbo.protocol.name=dubbo
dubbo.protocol.port=28080
TestDubboServiceFacade.version=1.0.0
TestDubboServiceFacade.timeout=30000
#Mybatis
#mybatis.mapper-locations=classpath:mapping/*.xml
#mybatis.type-aliases-package=org.example.mybatis
\ No newline at end of file
___ _ _ _
/ _ \(_) __ _ _ __ | |__ __ _ ___ / \ _ __ _ __
| | | | |/ _` | '_ \| '_ \ / _` |/ _ \ _____ / _ \ | '_ \| '_ \
| |_| | | (_| | | | | |_) | (_| | (_) |_____/ ___ \| |_) | |_) |
\__\_\_|\__,_|_| |_|_.__/ \__,_|\___/ /_/ \_\ .__/| .__/
|_| |_|
v${project.version}
\ No newline at end of file
# ===================================================================
# Spring Boot configuration.
#
# This configuration will be overriden by the Spring profile you use,
# for example application-dev.yml if you use the "dev" profile.
# ===================================================================
# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ==================================================================
server:
servlet:
session:
cookie:
http-only: true
tomcat:
max-http-header-size: 3145728
spring:
jackson:
serialization:
write_dates_as_timestamps: false
indent_output: true
datasource:
hikari:
minimum-idle: 1
maximum-pool-size: 3
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
jpa:
show-sql: true
hibernate:
ddl-auto: none
properties:
hibernate.cache.use_query_cache: false
hibernate.cache.use_second_level_cache: false
hibernate.cache.generate_statistics: false
dubbo:
scan: org.example.dubbo
thymeleaf:
cache: false
mode: HTML5
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
servlet:
content-type: text/html
resources:
add-mappings: true
static-locations: classpath:/static/
favicon:
enabled: false
mvc:
throw-exception-if-no-handler-found: true
view:
prefix: classpath:/view/
suffix: .jsp
static-path-pattern: /**
\ No newline at end of file
# ===================================================================
# Spring Boot configuration.
#
# This configuration will be overriden by the Spring profile you use,
# for example application-dev.yml if you use the "dev" profile.
# ===================================================================
# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ==================================================================
spring:
quartz:
jdbc:
initialize-schema: never
flyway:
enabled: false
batch:
initialize-schema: never
cloud:
task:
initialize:
enable: false
messages:
basename: i18n/messages
\ No newline at end of file
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.mariadb.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/employees</property>
<!-- JDBC connection pool (use the built-in) -->
<!--
<property name="connection.pool_size">1</property>
-->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<mapping class="org.example.jpa.entity.UserEntity"/>
<!-- Drop and re-create the database schema on startup -->
<!--
<property name="hbm2ddl.auto">update</property>
-->
</session-factory>
</hibernate-configuration>
\ No newline at end of file
# Error page
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<appender name="ROLLINGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logging.dir}/${project.name}/${project.name}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logging.dir}/${project.name}/${project.name}.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>90</maxHistory>
</rollingPolicy>
<encoder>
<charset>utf-8</charset>
<Pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}][%p][%X{sessionId}][%X{traceId}][${spring.profiles.active}][%X{userId}][%t|%logger{1.}|%M|%X{ctime}] - %msg %ex{full}%n</Pattern>
</encoder>
</appender>
<appender name="ASYNC_ROLLINGFILE" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>512</queueSize>
<appender-ref ref="ROLLINGFILE"/>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %ex{full}%n</pattern>
</encoder>
</appender>
<logger name="org.example" level="ERROR"/>
<logger name="javax.activation" level="ERROR"/>
<logger name="org.quartz.core" level="ERROR"/>
<logger name="org.quartz.simpl" level="ERROR"/>
<logger name="com.zaxxer.hikari.pool" level="ERROR"/>
<logger name="com.alibaba.dubbo.common.extension" level="ERROR"/>
<logger name="org.apache.zookeeper" level="ERROR"/>
<logger name="org.apache.curator" level="ERROR"/>
<logger name="org.apache.catalina.loader" level="ERROR"/>
<logger name="org.apache.catalina.util" level="ERROR"/>
<logger name="org.apache.catalina.core" level="ERROR"/>
<logger name="org.hibernate.hql" level="ERROR"/>
<logger name="org.hibernate.loader" level="ERROR"/>
<logger name="org.hibernate.type" level="ERROR"/>
<logger name="org.hibernate.persister" level="ERROR"/>
<logger name="org.hibernate.cfg" level="ERROR"/>
<logger name="org.hibernate.mapping" level="ERROR"/>
<logger name="org.hibernate.jpa.event" level="ERROR"/>
<logger name="org.hibernate.validator.internal" level="ERROR"/>
<logger name="org.hibernate.engine.internal" level="ERROR"/>
<logger name="org.hibernate.boot.model" level="ERROR"/>
<logger name="org.hibernate.boot.internal" level="ERROR"/>
<logger name="org.apache.tomcat.util" level="ERROR"/>
<logger name="org.springframework.orm" level="ERROR"/>
<logger name="org.springframework.jmx" level="ERROR"/>
<logger name="org.springframework.jndi" level="ERROR"/>
<logger name="org.springframework.aop" level="ERROR"/>
<logger name="org.springframework.web" level="ERROR"/>
<logger name="org.springframework.context" level="ERROR"/>
<logger name="org.springframework.core" level="ERROR"/>
<logger name="org.springframework.beans" level="ERROR"/>
<logger name="org.springframework.boot.web" level="ERROR"/>
<logger name="org.springframework.boot.actuate" level="ERROR"/>
<logger name="org.springframework.boot.context" level="ERROR"/>
<logger name="org.springframework.boot.autoconfigure.logging" level="ERROR"/>
<!--<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>-->
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="ERROR"/>
<logger name="org.hibernate.engine.QueryParameters" level="ERROR"/>
<logger name="org.hibernate.SQL" level="ERROR" />
<root level="${logging.level}">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ASYNC_ROLLINGFILE"/>
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.example.mybatis.mapper.DepartmentsMapper">
<resultMap id="BaseResultMap" type="org.example.mybatis.entity.DepartmentsEntity">
<id column="dept_no" jdbcType="CHAR" property="deptNo" />
<result column="dept_name" jdbcType="VARCHAR" property="deptName" />
</resultMap>
<sql id="Base_Column_List">
dept_no, dept_name
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from departments
where dept_no = #{deptNo,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from departments
where dept_no = #{deptNo,jdbcType=CHAR}
</delete>
<insert id="insert" parameterType="org.example.mybatis.entity.DepartmentsEntity">
insert into departments (dept_no, dept_name)
values (#{deptNo,jdbcType=CHAR}, #{deptName,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="org.example.mybatis.entity.DepartmentsEntity">
insert into departments
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptNo != null">
dept_no,
</if>
<if test="deptName != null">
dept_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptNo != null">
#{deptNo,jdbcType=CHAR},
</if>
<if test="deptName != null">
#{deptName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="org.example.mybatis.entity.DepartmentsEntity">
update departments
<set>
<if test="deptName != null">
dept_name = #{deptName,jdbcType=VARCHAR},
</if>
</set>
where dept_no = #{deptNo,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="org.example.mybatis.entity.DepartmentsEntity">
update departments
set dept_name = #{deptName,jdbcType=VARCHAR}
where dept_no = #{deptNo,jdbcType=CHAR}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--这里的loacation是你连接数据库的jar包,可以从项目依赖里面找-->
<classPathEntry location="e:\repository\mysql\mysql-connector-java\5.1.46\mysql-connector-java-5.1.46.jar"/>
<context id="context">
<!-- 是否生成注释 -->
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!-- 数据库连接,数据库版本高的话需要添加时区serverTimezone=GMT%2B8 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/employees"
userId="root" password="111111" />
<!-- 生成的包名和工程名 -->
<javaModelGenerator targetPackage="org.example.jpa.entity.mysql"
targetProject="src/main/java/"/>
<!-- xml映射文件 -->
<sqlMapGenerator targetPackage="mapping"
targetProject="src/main/resources/" />
<!-- mapper接口 -->
<javaClientGenerator targetPackage="org.example.mybatis.mapper"
targetProject="src/main/java/" type="XMLMAPPER" />
<!-- 数据库表 以及是否生成example,可以同时生成多个-->
<table tableName="departments" domainObjectName="DepartmentsEntity"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" />
</context>
</generatorConfiguration>
\ No newline at end of file
package rules;
import org.example.mybatis.entity.Person
import org.example.drools.PersonRuleAction;
dialect "java"
rule "hello,word"
when
eval(true)
then
System.err.println("hello,word!");
end
// 根据名字匹配指定的人
rule "1.find target person"
when
$p : Person( name == "bob" )
then
PersonRuleAction.doParse($p, drools.getRule());
System.out.println("Rule name is [" + drools.getRule().getName() + "]");
System.out.println("Rule package is [" + drools.getRule().getPackageName() + "]");
end
// 根据年龄匹配找到打工人
rule "2.find the work person"
when
$p : Person( age >= 25 && age < 65 )
then
System.out.println( $p + " is a work person!" );
end
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name/>
<param-value/>
</context-param>
</web-app>
the template files.
\ No newline at end of file
the template files.
\ No newline at end of file
package org.example;
import java.util.Arrays;
import org.example.mybatis.entity.Person;
import org.example.rest.PersonRuleController;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class PersonRuleControllerTest {
@Autowired
PersonRuleController controller;
@Test
public void testOnePerson() {
Person bob = new Person();
bob.setName("bob");
controller.fireAllRules4One(bob);
}
@Test
public void testTwoPerson() {
Person bob = new Person();
bob.setAge(33);
Person other = new Person();
other.setAge(88);
controller.fireAllRules4List(Arrays.asList(bob, other));
}
}
package org.example;
import cn.quant.spring.util.IdentitySequencer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* <p><b>JUnit VM Option:</b><br/>
* <code>-Dspring.config.file=${project.build.directory}/target/config/application-dev.properties </code><br/>
* </p>
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ServerApplication.class})
public class TestApplication {
@Autowired
private IdentitySequencer identitySequencer;
@Test
public void idWorker() {
System.out.println(identitySequencer.nextId());
System.currentTimeMillis();
return;
}
}
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