compile problems - do I need to switch back to Eclipse :(?
Hi,
I have a problem in my Slick example as described here: https://groups.google.com/forum/#!topic/scalaquery/tMnwCtMMLnE
In Eclipse it compiles fine. It seems IntelliJ's Scala plugin has problems in not recognizing macros or implicits? Here is my code:
build.gradle file:
=============================================
buildscript {
ext {
springBootVersion = '1.2.0.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'scala'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'eclipse'
sourceCompatibility = 1.8
targetCompatibility = 1.8
war {
baseName = 'mamas-kitchen'
version = '1.0.0'
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile project(":mamaskitchen-common")
compile 'org.scala-lang:scala-library:2.11.4'
//compile 'com.typesafe.slick:slick_2.11:2.1.0'
compile 'com.typesafe.slick:slick_2.11:3.0.0-M1'
compile 'com.fasterxml.jackson.module:jackson-module-scala_2.11:2.4.4'
//base dependencies for Spring Boot
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-logging:${springBootVersion}")
//uses the latest HSQLDB version (2.3.2) for Spring Boot
compile("org.hsqldb:hsqldb:2.3.2")
// We use Scalatest for testing our library
testCompile 'junit:junit:4.12'
testCompile 'org.scalatest:scalatest_2.11:2.2.3'
testCompile "org.springframework.boot:spring-boot-starter-test"
testRuntime 'org.scala-lang.modules:scala-xml_2.11:1.0.3'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
=============================================
My Scala classes:
=============================================
case class User(email: String, password: String, id: Option[Long] = None)
class Users(tag: Tag) extends Table[User](tag, "user") {
def id = column[Long]("ID", O.PrimaryKey, O.AutoInc)
def email = column[String]("EMAIL")
def password = column[String]("PASSWORD")
def * = (email, password, id.?) <> (User.tupled, User.unapply)
}
@Configuration
@EnableAutoConfiguration
@ComponentScan
class ApplicationConfig
object Application extends App {
def log = LoggerFactory.getLogger(this.getClass());
SpringApplication.run(classOf[ApplicationConfig], args:_ *)
//override def main(args: Array[String]) = SpringApplication.run(classOf[ApplicationConfig], args:_ *)
val users = TableQuery[Users]
val db = Database.forURL("jdbc:hsqldb:mem:mymemdb", driver = "org.hsqldb.jdbc.JDBCDriver")
val setup = Action.seq(
// create the schema
users.schema.create,
// insert two User instances
users += User("John Doe", "xxx"),
users += User("Fred Smith", "xxx")
)
Await.result(db.run(setup), Duration.Inf)
//compile error appears here on the unknown result method which is in the class
//StreamingQueryActionExtensionMethodsImpl (from JdbcActionComponent.class)
//is this an implicit?
Await.result(db.run(users.result), Duration.Inf)
}
=============================================
The error appears in the last line: Await.result(db.run(users.result), Duration.Inf) and IntelliJ complains 'Cannot resolve symbol result'.
I am working with the latest Scala plugin 1.2.1 and IntelliJ Community Edition 14.0.2.
Not sure whether this is a similar problem but I have found this old post from 2013 about highlighting problems: http://stackoverflow.com/questions/20847928/slick-2-0-and-intellij-highlighting-errors
请先登录再写评论。
In IntelliJ I can start my Application class - so the compiler is correct. The problem is when I open my Application.scala file. The editor complains then 'Cannot resolve symbol result'.
Has it something to do how I import my project into IntelliJ? All I did is 'Import Project' and select the build.gradle file.
What are facets? Do I need to manually install a Scala facet?
I created a ticket, I'll check it a bit later: https://youtrack.jetbrains.com/issue/SCL-8079
Please follow the issue, probably I'll give you some workaround.
Generally, wrong error highlighting in IntelliJ IDEA Scala plugin is possible.
Best regards,
Alexander Podkhalyuzin.
Your example is incomplete, I wasn't able to complete it myself, can you provide example project and attach it to issue https://youtrack.jetbrains.com/issue/SCL-8079
Best regards,
Alexander Podkhalyuzin.
I have create a simple sample on GitHub. See here: https://github.com/AlienSource/scala-slick-springboot-sample
All you need to do then is to import the build.gradle file in the server folder. The error appears in the last line of code of Application.scala