I am doing my first Lift project and want to add a database. Following a book, I added the following dependency to build.sbt:
"net.liftweb" %% "lift-mapper" % liftVersion % "compile",
And then, in Boot.scala, the import
import net.liftweb.mapper._
Now the project doesn't compile, with Boot.scala giving the error
object mapper is not a member of package net.liftweb
But other sources around the Internet seem to suggest that my imports are OK.
Where does the dependency problem come from?
It turned out that this is a problem of Eclipse, which cannot setup the dependencies correctly.
I had to close the project in Eclipse and delete the hidden files .classpath and .project. Then get into SBT and run
eclipse
(the project has to use the sbteclipse plugin as described in the Lift cookbook). This recreates the project files with the correct dependencies.
Afterwards, Eclipse compiled the code as expected. It seems this will be needed every time a change is made to build.sbt.
Related
I have imported Scala project from the Version control (Git). In the build.sbt not recognizing name, version control etc. In the assembly.sbt below line is not recognizing.
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
I tried couple of things added language support for Scala, enable auto import etc but still no luck. In the build.sbt i don't see sbt in the right side of panel as shown in the picture.
enter image description here
Below is different project where I can see sbt support in the project.
I am new scala and SBT. I am trying write a pursuing engine which can read the JSON string to object and write back Object to JSON string. To do that I am using eclipse as IDE and SBT(0.13.13) as build tool and jackson. I am getting some error while trying to import the dependency in scala file. My steps as follows:
I have added this two dependency in build.sbt of my project
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.5.3"
libraryDependencies += "com.fasterxml.jackson.module" % "jackson-module-scala_2.11" % "2.8.8"
Compile the project from SBT console with "compile" command
Creating a scala object for DAO object, which will contain the data and transfer as JSON
But when I am trying to import this in scala source file:
import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
It's giving some compilation error:
object fasterxml is not a member of package com
But my compilation, which I did to download those dependency, ends up with success and showing download as [SUCCESSFUL]
I think I am missing something, can any one help me out in this regard?
As part of experiment I have added MySql dependency in my project as:
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.40"
Which is working properly, I am able to connect the MySql Server from scala code.
One more thing as in Maven we can update or if we save the POM file, maven downloads all those dependency automatically. Is that the same in SBT or every time after adding dependency in build.sbt I have to "reload" and "compile" to download?
Here are some of the steps you need to follow
1) clean your project in eclipse (eclipse might cache dependencies)
2) make sure your project directories are as explained in here
3) If above two steps doesn't work do
import _root_.com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import _root_.com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
import _root_.com.fasterxml.jackson.module.scala.DefaultScalaModule
Hope you get it solved
I am trying to add this Scala Library into Eclipse so as to add available functions I can use on Actors.
I've downloaded the file and extracted it and tried adding it to my workspace in the project explorer, but when I try, Eclipse tells me it can't find any projects in the file. I'm sure that there is a tutorial or something online that explains exactly how to do this, but like I said, I'm not sure about all the terminology, so I don't know what to search for to get the result I want.
The easiest way is to create an sbt project and use the sbteclipse plugin.
Your project structure should look like this:
build.sbt
project/build.properties
project/eclipse.sbt
build.sbt
(note that lines of code should be separated by a white line)
name := "ProjectName"
libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.2"
build.properties
sbt.version=0.13.5
eclipse.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
Then from the root directory execute sbt and within the sbt command line execute eclipse or eclipse with-sources=true
You can use sbt-extras or activator to get a specialized version that will automatically download the correct sbt version based on the build.properties file.
You could add the sbteclipse plugin as a default plugin, making it available in all projects by creating eclipse.sbt in the ~/.sbt/0.13/plugins directory instead of the project directory
If you created your project via sbt, please follow the instruction on the github page of async. Namely, add this libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.2" to build.sbt, run sbt, regenerate eclipse files with "eclipse" command and finally re-import project into eclipse
I am trying to add Scalding 2.10 as a managed dependency via build.sbt like so:
name := "ss"
version := "1.0"
libraryDependencies += "com.twitter" % "scalding_2.10" % "0.10.0"
IntelliJ downloads the jar and adds it as an external library (see screen below) but fails to resolve the com.twitter namespace.
I have tried both invalidating the IntelliJ cache and generating project files via sbt gen-idea but neither solutions have worked. Any ideas would be greatly appreciated.
The scalding jar file scalding_2.10 has no code in it to compile against. Its just 300 Bytes in size.
The correct dependency I feel should be
libraryDependencies += "com.twitter" % "scalding-core_2.10" % "0.11.1"
As the comment suggest try rm-ing your ivy2 cache, and try sbt gen-idea. If that doesn't work, other things to check:
makes sure you have indeed got the scala plugin installed.
Most likely you're java SDK is not set or pointing somewhere wrong; right click the project dir, click "Open Module Settings", go to SDK and make sure the path is correctly set to the jdk otherwise syntax highlighting will likely break.
To test your deps have been properly pulled in from tinternet, try sbt compile; if it compiles then you should indeed have downloaded the dependency properly.
I added the Mailer plugin to my Play Framework 2 project. It compiles and works fine, but IntelliJ can't resolve any of its classes. I would normally just add the jar as a module in my IntelliJ project settings, but I don't have a jar. As far as I understand, the plugin is automatically being pulled from some repository. So how do I make IntelliJ aware of it?
I added this to conf/play.plugins
1500:com.typesafe.plugin.CommonsMailerPlugin
And this as a dependency in project/build.scala
"com.typesafe" %% "play-plugins-mailer" % "2.0.4"
I resolve problems like this with the sbt-idea SBT plugin. Just add this to your project/plugins.sbt file:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0")
Then, whenever you change your project dependencies, run sbt idea and your IntelliJ project will be updated.
I had to delete the reference to com.github.mpeltonen in my plugins.sbt file first. Then as Bill said, I needed to run play idea. If I tried to run play idea without deleting the reference I got this exception:
java.lang.NoSuchMethodError: org.sbtidea.SbtIdeaPlugin$.ideaSettings()Lscala/collection/Seq;