我对光滑及其TableQueries感到有点失望:应用程序的模型可以是"类Persons(tag:Tag)扩展表[Person]例如(其中Person是一个案例类,其中包含名称,年龄,地址等字段...).奇怪的一点是"val persons = TableQuery [Persons]"包含所有记录.
举例来说,我们可以使用:
adults = persons.filter(p => p.age >= 18).list()
Run Code Online (Sandbox Code Playgroud)
数据库的内容是否在变量人员中加载?相反,是否有一种机制可以评估不是"人"而是"成年人"?(一种懒惰的变量)?我们可以说"在任何时候",人们"包含整个数据库"吗?
有没有好的做法,一些可以帮助开发人员的重要想法?
谢谢.
我创建了一个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) 我不能将元组作为方法参数传递:
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)
谢谢.
我在尝试使用 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) 使用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) 我想使用 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) 我尝试使用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) 我使用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) 如标题中所述,我无法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的更改被拒绝.为什么?
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)