我已经使用 gradle 一段时间了,并且喜欢这个应用程序插件,它允许您创建包含命令行运行程序的 dist 包,这样您就不必担心设置类路径等。
最近我看到几个项目(即 dropwizard)建议使用 fat jar 文件。使用 gradle 中的 dist 包,我实际上并不认为需要创建 fat jar 文件。
我对 fat jar 文件有什么遗漏吗?
在我的应用程序中,我使用hibernate,连接数据库并创建会话.这是我的hibernate.cfg.xml文件.还行吧.它运作正常.
<?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">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/country</property>
<property name="connection.username">root</property>
<property name="connection.password">password</property>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试db.property file使用hibernate.cfg.xml它来读取数据库配置属性时,它显示了Exception,这是我的另一个hibernate.cfg.xml文件
<util:properties id="db" location="classpath:db.properties" />
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="driverClassName" value="#{db['driverClassName']}"></property>
<property name="url" value="#{db['url']}"></property>
<property name="username" value="#{db['username']}"></property>
<property name="password" value="#{db['password']}"></property>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
这是错误
org.dom4j.DocumentException: Error on line 8 of document : The prefix "util" for element "util:properties" is not bound. …Run Code Online (Sandbox Code Playgroud) 1)在LinkedList实现中,所有3个成员的变量大小,第一个,最后一个是瞬态的,那么实现serializable的用途是什么?
2)当我们尝试序列化LinkedList时会持续什么?
我有这个类层次结构
学生类.java
public class StudentClass {
private List<Student> studentList;
public List<Student> getStudentList() {
return studentList;
}
public void setStudentList(List<Student> studentList) {
this.studentList = studentList;
}
}
Run Code Online (Sandbox Code Playgroud)
学生.java
public class Student {
private Child child;
private int studAge;
public Student(Child child, int studAge) {
this.child = child;
this.studAge = studAge;
}
public Child getChild() {
return child;
}
public void setChild(Child child) {
this.child = child;
}
public int getStudAge() {
return studAge;
}
public void setStudAge(int studAge) {
this.studAge = …Run Code Online (Sandbox Code Playgroud) 我以前有一个@SequenceGenerator带参数的代码allocationSize=1
我需要SequenceGenerator使用custom 覆盖@GenericGenerator。但是,我看不到allocationSize在自定义GenericGenerator策略类中指定参数的方法。我能做什么?
我有一个查询如下,
SELECT count(*) from Employee where e_id IN (121, 234, 536, 234).
Run Code Online (Sandbox Code Playgroud)
在上面的查询中,234重复了两次。
但上面的查询返回结果为count = 34,而不是 4。
我的问题是,当我没有使用时,如何在 Select 查询中过滤重复数据DISTINCT。
或者数据库如何处理 IN 子句,它是List(重复值)还是Set(唯一值)或两者都不是。
假设我有2节课.
课程班
public class Course {
private int id;
private String name;
}
Run Code Online (Sandbox Code Playgroud)
学生班
public class Student {
private int id;
private String name;
private List<Course> courses;
}
Run Code Online (Sandbox Code Playgroud)
我有List<Student>,每个人Student都注册了多门课程.
我需要使用Java 8流API过滤掉结果,如下所示.
Map<courseId, List<Student>>
Run Code Online (Sandbox Code Playgroud)
我在下面试过,但没有成功:
第一种方法
Map<Integer, List<Student>> courseStudentMap = studentList.stream()
.collect(Collectors.groupingBy(
student -> student.getCourses().stream()
.collect(Collectors.groupingBy(Course::getId))));
Run Code Online (Sandbox Code Playgroud)
第二种方法
Map<Integer, List<Student>> courseStudentMap = studentList.stream()
.filter(student -> student.getCourses().stream()
.collect(Collectors.groupingBy(
Course::getId, Collectors.mapping(Student::student, Collectors.toList()))));
Run Code Online (Sandbox Code Playgroud) 我正在构建几个要运行的 cron,我需要在服务器启动一段时间后运行的 cron 之一。
<task:scheduled ref="myCron"
method="processData" cron="0/15 * * * * ?" initial-delay="45000"></task:scheduled>
Run Code Online (Sandbox Code Playgroud)
我需要每 15 秒运行一次这个 cron,它确实做到了。但是我需要在服务器启动 45 秒后运行这个 cron,而不是立即运行。
下面是我的xsd,
<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:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd"
default-lazy-init="false">
Run Code Online (Sandbox Code Playgroud)
例外
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: the 'initial-delay' attribute may not be used with cron and trigger tasks
Run Code Online (Sandbox Code Playgroud) 方法java.util.Date方法.equals是否与所涉及的事物无关date format?我的意思是我已经尝试过date.before和date.after不同的格式,它们表现正常,但是,我不确定 ,因为Date.equals我担心它的表现与 一样java.lang.Object.equals,我正在寻求一个坚定而明确的答案。
用法 - Angular NVD3 LineChart
我正在获取数据,但是当数据为0时,它会绘制图形并绘制范围为-1,0,1的 y轴.
但我确实想在负y轴上绘图,因为我的数据永远不会是负数.
X轴包含时间.
我的图表随着时间的推移而增加,问题就像前几分钟数据将为0,然后我将开始获取数据.
JavaScript代码
$scope.options = {
chart: {
type: 'lineChart',
height: 120,
margin : {
top: 8,
bottom: 30,
left:40,
right:50,
},
color: ['#e4a91d','#444fa2','#de0000']
, showLegend: false
, wrapLabels: true
, tooltips:true
, reduceXTicks: false,
x: function(d){ return d[0]; },
y: function(d){ return d[1]; },
showDistY: true,
showDistX: true,
useInteractiveGuideline: true,
transitionDuration: 10,
xAxis: {
axisLabel: '',
tickFormat: function(d) {
return d3.time.format('%H:%M')(new Date(d));
},
tickPadding: 10,
axisLabelDistance: 1,
ticks: …Run Code Online (Sandbox Code Playgroud) java ×7
hibernate ×2
mysql ×2
angular-nvd3 ×1
angularjs ×1
cron ×1
distinct ×1
evaluation ×1
expression ×1
gradle ×1
jar ×1
java-8 ×1
java-stream ×1
jpa ×1
linechart ×1
mvel ×1
nested-loops ×1
orm ×1
spring ×1
sql ×1