小编Ank*_*hal的帖子

Fat Jar 与 Gradle 中的应用程序包相比的优势

我已经使用 gradle 一段时间了,并且喜欢这个应用程序插件,它允许您创建包含命令行运行程序的 dist 包,这样您就不必担心设置类路径等。

最近我看到几个项目(即 dropwizard)建议使用 fat jar 文件。使用 gradle 中的 dist 包,我实际上并不认为需要创建 fat jar 文件。

我对 fat jar 文件有什么遗漏吗?

java jar gradle

5
推荐指数
1
解决办法
1400
查看次数

如何在hibernate中使用属性文件读取数据库配置参数

在我的应用程序中,我使用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)

java mysql hibernate

5
推荐指数
2
解决办法
4万
查看次数

由于java LinkedList的所有成员变量都是瞬态的,因此实现Serializable的用途是什么?

1)在LinkedList实现中,所有3个成员的变量大小,第一个,最后一个是瞬态的,那么实现serializable的用途是什么?

2)当我们尝试序列化LinkedList时会持续什么?

java

5
推荐指数
1
解决办法
438
查看次数

Mvel 迭代列表

我有这个类层次结构

学生类.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)

java evaluation expression mvel

5
推荐指数
1
解决办法
3148
查看次数

设置@GenericGenerator的分配大小

我以前有一个@SequenceGenerator带参数的代码allocationSize=1

我需要SequenceGenerator使用custom 覆盖@GenericGenerator。但是,我看不到allocationSize在自定义GenericGenerator策略类中指定参数的方法。我能做什么?

java orm hibernate jpa

5
推荐指数
1
解决办法
617
查看次数

使用 IN 子句选择查询 - IN 子句中有重复值

我有一个查询如下,

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(唯一值)或两者都不是。

mysql sql distinct

5
推荐指数
2
解决办法
6255
查看次数

流 - 嵌套集合 - 转换为地图

假设我有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)

nested-loops java-8 java-stream

5
推荐指数
1
解决办法
96
查看次数

'initial-delay' 属性不能与 cron 和 trigger 任务一起使用

我正在构建几个要运行的 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 cron spring scheduled-tasks

3
推荐指数
1
解决办法
6516
查看次数

java.util.Date 库中用于日期比较的 equals 方法

方法java.util.Date方法.equals是否与所涉及的事物无关date format?我的意思是我已经尝试过date.beforedate.after不同的格式,它们表现正常,但是,我不确定 ,因为Date.equals我担心它的表现与 一样java.lang.Object.equals,我正在寻求一个坚定而明确的答案。

java

1
推荐指数
1
解决办法
3202
查看次数

y轴 - 最小 - 最大范围 - 角度NVD3 - 折线图

用法 - 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)

linechart angularjs angularjs-directive angular-nvd3

1
推荐指数
1
解决办法
3511
查看次数