小编lol*_*ley的帖子

光滑和scala:什么是TableQueries?

我对光滑及其TableQueries感到有点失望:应用程序的模型可以是"类Persons(tag:Tag)扩展表[Person]例如(其中Person是一个案例类,其中包含名称,年龄,地址等字段...).奇怪的一点是"val persons = TableQuery [Persons]"包含所有记录.

举例来说,我们可以使用:

adults = persons.filter(p => p.age >= 18).list()
Run Code Online (Sandbox Code Playgroud)

数据库的内容是否在变量人员中加载?相反,是否有一种机制可以评估不是"人"而是"成年人"?(一种懒惰的变量)?我们可以说"在任何时候",人们"包含整个数据库"吗?

有没有好的做法,一些可以帮助开发人员的重要想法?

谢谢.

scala slick

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

无法从scala访问java静态方法

我创建了一个java和scala混合的程序,但是我在尝试从scala调用java静态方法时遇到错误.这是代码:

object GestionBasesScala {

  def sors_tout_de_suite() {

    application.launcher.append("SCALA : exit")
  }
}
Run Code Online (Sandbox Code Playgroud)

启动器类的append方法是这样的(在java中):

public static void append(String text) {

    if (name_of_file != null && name_of_file != "") {
        BufferedWriter bufWriter = null;
        FileWriter fileWriter = null;
        try {
            fileWriter = new FileWriter(name_of_file, true);
            bufWriter = new BufferedWriter(fileWriter);
            // Ins�rer un saut de ligne
            bufWriter.newLine();
            bufWriter.write(text);
            bufWriter.close();
        } catch (IOException ex) {
              //     Logger.getLogger(TextFileWriter.class.getName()).log(Level.SEVERE,
            // null, ex);
        } finally {
            try {
                bufWriter.close();
                fileWriter.close();
            } catch (IOException ex) {
                // Logger.getLogger(TextFileWriter.class.getName()).log(Level.SEVERE, …
Run Code Online (Sandbox Code Playgroud)

mixed static scala scala-java-interop

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

scala:将元组作为函数的参数是不可能的

我不能将元组作为方法参数传递:

scala> val c:Stream[(Int,Int,Int)]= Stream.iterate((1, 0, 1))((a:Int,b:Int,c:Int) => (b,c,a+b))
<console>:11: error: type mismatch;
 found   : (Int, Int, Int) => (Int, Int, Int)
 required: ((Int, Int, Int)) => (Int, Int, Int)
Run Code Online (Sandbox Code Playgroud)

谢谢.

scala tuples

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

groovy.lang.MissingPropertyException:无法为 org.gradle.api.Project 类型的项目“:flamingo”设置未知属性“versionKey”

我在尝试使用 intelliJ 编译 java 火烈鸟图形工具时遇到此错误。

这是错误项目的 build.gradle 文件:

import javax.swing.SwingUtilities

dependencies {
  compile project(":trident")
  compile group: 'org.tmatesoft.svnkit', name: 'svnkit', version:'1.2.3.5521'
  compile group:'org.apache.xmlgraphics', name:'batik-swing', version:'1.7'
  compile (group:'org.apache.xmlgraphics', name:'batik-transcoder', version:'1.7') {
    exclude group:'xml-apis'
    exclude group:'xalan'
    exclude group:'commons-io'
    exclude group:'commons-logging'
    exclude group:'org.apache.avalon.framework'
  }
  testCompile group: 'com.jgoodies', name: 'forms', version: '1.2.0'
  testCompile group: 'junit', name: 'junit', version: '4.3.1'
  testCompile group: 'org.easytesting', name: 'fest-assert', version: '1.2'
  testCompile group: 'org.easytesting', name: 'fest-reflect', version: '1.2'
  testCompile group: 'org.easytesting', name: 'fest-swing', version: '1.2.1'
  testCompile group: 'org.easytesting', name: 'fest-swing-junit', …
Run Code Online (Sandbox Code Playgroud)

java swing gradle radiance-flamingo

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

slick'n scala:没有.ddl字段的TableQuery对象

使用scala,slick 2.0和eclipse我有一个错误我无法解释:"value ddl不是scala.slick.lifted.TableQuery [SqliteSpec.this.Personnes]的成员"

这是代码:我声明了这样一个特征:

trait sqlite {

val db = Database.forURL("jdbc:sqlite:rdvs.txt", driver = "org.sqlite.JDBC")

class Personnes(tag: Tag) extends Table[Rdv](tag, "RDV") {

  def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
  def nom = column[String]("NOM", O.NotNull)
  def prénom = column[String]("PRENOM")
  def sexe = column[Int]("SEXE")
  def télPortable = column[String]("TELPOR")
  def télBureau = column[String]("TELBUR")
  def télPrivé = column[String]("TELPRI")
  def siteRDV = column[String]("SITE")
  def typeRDV = column[String]("TYPE")
  def libelléRDV = column[String]("LIBELLE")
  def numRDV = column[String]("NUMRDV")
  def étape = column[String]("ETAPE")
  def dateRDV = column[Date]("DATE")
  def heureRDVString = …
Run Code Online (Sandbox Code Playgroud)

scala traits slick

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

使用 easymock 无需注入模拟

我想使用 easymock 3.5 和 JUnit5 编写一个小示例,但在尝试注入模拟时出现错误 (nullPointerException)...

这是测试代码:

package model;

import controler.BookEditor;
import org.easymock.EasyMockRule;
import org.easymock.EasyMockSupport;
import org.easymock.Mock;
import org.easymock.TestSubject;
import org.junit.Before;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import view.BookWindow;

import static org.junit.jupiter.api.Assertions.assertEquals;

//@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class BookTest extends EasyMockSupport {

@Rule
public EasyMockRule rule = new EasyMockRule(this);


@Mock
public BookWindow bookWindow;

public BookList bookList;

@TestSubject
public BookEditor bookEditor;

@Before
public void setUp() {
  bookList = new BookList();
  bookEditor = new BookEditor(bookList, bookWindow);
}

@Test
public void testBookCreation() {

  Book le_livre_de_la_jungle = new …
Run Code Online (Sandbox Code Playgroud)

java easymock maven junit5

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

斯卡拉的尖顶框架:我无法对一个团队进行操作

我尝试使用spire,一个数学框架,但我有一条错误消息:

import spire.algebra._
import spire.implicits._

trait AbGroup[A] extends Group[A]

final class Rationnel_Quadratique(val n1: Int = 2)(val coef: (Int, Int)) {
  override def toString = {
    coef match {
        case (c, i) =>
            s"$c + $i?$n"
    }
  }

  def a() = coef._1

  def b() = coef._2

  def n() = n1


} 

object Rationnel_Quadratique {

  def apply(coef: (Int, Int),n: Int = 2)= {
    new Rationnel_Quadratique(n)(coef)
  }

}

object AbGroup {

  implicit object RQAbGroup extends AbGroup[Rationnel_Quadratique] {

    def +(a: Rationnel_Quadratique, b: Rationnel_Quadratique): Rationnel_Quadratique …
Run Code Online (Sandbox Code Playgroud)

math scala spire

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

java 10 gradle项目:找不到自动模块

我使用gradle创建了一个带有intelliJ的java 10项目.我复制了一些东西(一些使用库guava和javaFx的"AppFx"类,以及一个个人的build.gradle文件).我还在src/main/java中添加了一个module-info.java文件,其中包含以下内容:

module biblio5.main {
    requires javafx.graphics;
    requires javafx.controls;
    requires javafx.base;
    requires guava;
}
Run Code Online (Sandbox Code Playgroud)

其中grava是一个自动模块.

这是build.gradle的相关部分:

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile 'com.google.guava:guava:23.0'
}
Run Code Online (Sandbox Code Playgroud)

intelliJ可以编译项目(使用类似锤子的图标)但是当我从intelliJ运行compileJava gradle任务时,我收到一个错误:

13:12:46:执行任务'compileJava'......

任务:compileJava FAILED C:\ Users\lolve\Documents\gradle_java\biblio5\src\main\java\module-info.java:5:错误:找不到模块:guava需要guava; ^ 1错误

我花了很多时间在网上,但没有找到答案.

谢谢

ps:这是整个build.gradle:

buildscript {
    dependencies {
        classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.8.2'
        classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
    }
    repositories {

        maven {url "https://mvnrepository.com/artifact/de.dynamicfiles.projects.gradle.plugins/javafx-gradle-plugin"}
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        jcenter()
    }
}


plugins {
    id 'java'
    id 'application'
    id 'edu.sc.seis.launch4j' version '2.4.4'
}
apply …
Run Code Online (Sandbox Code Playgroud)

java intellij-idea gradle guava java-module

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

在for循环中赋值var arraybuffer:"重新分配给val"

如标题中所述,我无法Arraybuffer(Arraybuffer(Int,Int),Int)在for中重新分配类型的变量loop:

var ab1 = ArrayBuffer(le4: _*)
var ab2 = ab1 map (ligne => (ArrayBuffer(ligne._1: _*), ligne._2))
println("ab:" + ab2)

for {
    i <- 1 to ab2.length
    j <- 0 to i
} {
    ab2(i)._1(j)._2 = j match {
        case 0 =>  ab2(i - 1)._1(0)._2 + ab2(i)._1(j)._1
        case i =>  ab2(i - 1)._1(j - 1)._2 + ab2(i)._1(j)._1
        case _ =>  ab2(i - 1)._1(j)._2 + ab2(i - 1)._1(j - 1)._1 + ab2(i)._1(j)._1
    }
}
Run Code Online (Sandbox Code Playgroud)

关键点是ab2声明为var但是其中的Int的更改被拒绝.为什么?

for-loop scala

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

在一个光滑的查询中比较2个日期似乎很难

helllo

我无法改编这个代码示例:https://github.com/pedrofurla/slick-demo/blob/master/src/main/scala/slickdemo/domain/Person.scala.

它处理在光滑查询中比较日期的能力.难点在于您无法访问日期字段(例如提取年份,月份和日期),因为查询使用列类型.

我搜索并找到了上面的例子,但我无法适应它.

这是我的代码:

桌子:

class Personnes( tag : Tag ) extends Table[ Rdv ]( tag, "RDV" ) {

     def id = column[ Int ]( "ID", O.PrimaryKey, O.AutoInc )
     def nom = column[ String ]( "NOM", O.NotNull )
     def prénom = column[ String ]( "PRENOM" )
     def sexe = column[ Int ]( "SEXE" )
     def télPortable = column[ String ]( "TELPOR" )
     def télBureau = column[ String ]( "TELBUR" )
     def télPrivé = column[ String …
Run Code Online (Sandbox Code Playgroud)

scala jodatime slick

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