How to add auto-generated slick code to classpath

259 views Asked by At

I generated source code using the method described here

https://github.com/slick/slick-codegen-example/blob/master/build.sbt

This method works and now when I do compile I can see that the auto-generated Target.scala file is being successfully compiled as Tables.class

enter image description here

but in my source code, If I try to import the autogenerated class file. it says cannot resolve symbol demo

enter image description here

2

There are 2 answers

0
chengpohi On BEST ANSWER

This is caused by IntelliJ can't recognize the generated code, you can try to mark target/scala-2.11/src_managed/slick/ this as Sources Root. like:

enter image description here

0
kkurt On

You can also generate source file with the code below (example for MySql) :

slick.codegen.SourceCodeGenerator.main(
  Array("slick.jdbc.MySQLProfile", "com.mysql.jdbc.Driver", "jdbc:mysql://localhost:33000/MyDB?useSSL=false&autoReconnect=true", 
      "ABSOLUTE_PATH_FOR_FILE", "com.mypackage", "USER","PASS"))