IntelliJ SBT project cannot resolve SBT symbols - java

I'm banging my head against the wall on this one.
Trying to open a cloned git SBT project at work. It is a combined Java and Scala Play project, with scala 2.11.1, SBT 0.13.6, and Play 2.5.
I use IntelliJ to import project from the cloned repo, with JDK 1.8, and all download and SBT checkboxes checked, and then run either SBT refresh, or reload from SBT shell.
After doing so, all SBT and Play code on both build.sbt and plugins.sbt is painted red, as in "cannot resolve symbol".
Looking at Intellij poroject structure, I have JDK1.8 on the SDK tab, and scala-sdk-2.11 on the Global Libraries tab. SBT and Scala plugins are installed and enabled.
SBT refresh fails on the following Play dependency, which could be the reason for the above symptom, since the SBT build does not complete:
unresolved dependency:
com.typesafe.play.plugins#play-statsd_2.11;2.3.0: not found
The dependency does exist:
http://dl.bintray.com/typesafe/maven-releases/com/typesafe/play/plugins/play-statsd_2.11/2.3.0/
What am I doing wrong?

Turns out the problem is on the typesafe side, not on my env.
All typesafe dependencies on the project are resolved as expected, except for play-statsd.
I manually added this dependency to my ivy cache, and now everything works fine.
It was a hard one to isolate, because apparently everybody here already have the dependency on their caches, so seems like their updates work well...
If anyone has the same problem, fetch the dependency from the bintray repository, and manually add it to your ivy cache, e.g.
~/.ivy2/cache/com.typesafe.play.plugins/play-statsd_2.11
The github play-plugins repository has been archived, so I can't open an issue, and don'y know if anyone will take care of it anyway.

Unresolved dependency error usually related with Scala version that you are using.
Here is Play 2.3.x documentation.
https://www.playframework.com/documentation/2.3.x/Migration22#Update-Scala-version
If you are able to use Play 2.7.x, your issue will be fixed.

Could you please add Play StatsD dependency in build.sbt as below and check once.
"com.typesafe.play.plugins" %% "play-statsd" % "2.3.0"

You should add maven-releases resolver:
resolvers += "Typesafe Resolver" at "http://repo.typesafe.com/typesafe/maven-releases/"

Related

new dependency not recognised by Maven

Using maven version 3.6.3 and JDK version "openjdk-17"
I've tried using Maven's dependencies so I could use the xstream library in my project. Following a guide I added com.thoughtworks.xstream to my pom.xml file:
I then tried to use xstream, but intellij couldn't resolve "XStream" even though it seems to work for JavaFX just fine. This code does not compile.
EDIT: I loaded a new project, where I used, what I believe to be, up to date versions. Maven 3.8.1, the latest intellij version, and everything else (JDK, openjfx) at version 17.0.2 yet when I try to use "XStream" in my project code (after reloading the maven project) it says "Cannot resolve symbol XStream"
Edit 2:
I added junit to the dependencies, it works. I add Gson to the dependencies. It doesn't work.
I figured out that in the "modules-info.java" file, "requires xstream" is needed. That is all
One of the following may solve your problem:
These are based on my previous experiences.
because may be auto import disabled. re Import maven project.(intellij: press Ctrl+Shift+A then actions - input "reload" find "Reload All Maven Projects").
in my experience, sometimes it does happen that the dependency is not fully received. remove xstream special version folder from .m2 (com->thoughtworks->xstream) and repeat step 1.
maybe repository not valid. check repository source in file settings.xml in .m2 (if exist) or replace to other source.
invalid cache and restart (intellij: file-> invalid caches/restart). This has solved my problem several times.
Your access to the site or repository may be closed. check network policy or use vpn (Poor probability)

IntelliJ can't load Maven dependency

I'm using IntelliJ IDEA Community 2020.2.3.
My project is built around Kotlin 1.3.30 and Java 11.
I've upgraded one of my dependecy to java 11 too, and after that, the IDE shows the dependency under "External Libraries", it build the app without errors, Maven build it from terminal without error, but the IDE shows unresolved references on each occurrency of the classes, functions and imports of that library.
I already tried to empty the cache or deleting idea files and importing again the project, but none of those worked.
Any tips?
You can use CTRL+SHIFT+A and look for Load Maven Changes or CTRL+SHIRT+O to do the same thing

IntelliJ not recognizing dependencies imported by Maven?

I am not quite sure what has happened to my IntelliJ recently but any new projects created or checked out from a repo are unable to resolve the dependencies from maven.
Resulting in lots of unresolved class symbols.
Interestingly projects that have already existed work fine and IntelliJ can resolve the dependencies imported by Maven.
So something has happened within the space of the last two weeks that has caused this issue. I haven't touched the Intellij config
This is what I have done to troubleshoot:
clear cache in intellij
mvn clean and install
reimport through maven on intellij
download sources and documentation
remove maven pom and re-add it
checked m2/repository cache, which contains the libraries
IntelliJ version - 2018.2
Any ideas?

javax.servlet.http.HttpServlet was not found even if maven dependency exists

I have an issue with my Eclipse Neon configuration on my maven project. The issue that appears many times is the following The superclass "java.servlet.http.HttpServlet" was not found on the java build path. I know there were few posts about that and know also that there is two solutions. The first one is to add a Tomcat server on runtime and the second one is to add servlet dependency in the pom.xml.
As it's an SVN project, the depedency was already in it and anyone in my team has a Tomcat configured on runtime but the project is building well on their eclipse.
Any idea ?
The problem was that I had some errors when I built the project for the first time. The solution was to empty the m2 folder which is the local maven repository, then clean and build and it works.
You can also resolve this issue by Updating the Maven dependencies in your project. You can do this by
Right click on the project -> Maven -> Update Project

Java project with Gradle in IntelliJ IDEA: cannot resolve symbol 'google' but project compiles

I have a toy Java project set up with Gradle in IntelliJ IDEA 13.1.2. It compiles and runs fine, but the IDE highlights 'google' in
import com.google.common.base.Strings;
as red and warns "Cannot resolve symbol 'google'". Any idea how to fix it?
I have tried 1) deleting .idea/ and re-creating the project in IntelliJ IDEA, and 2) re-importing project from the manually created Gradle configuration file build.gradle, but to no avail.
I think user Sap is correct, at least in my case. You should not have to manually add the dependency.
Did you change the dependencies in the gradle file without syncing intellij? Try this button:
For more information, see:
https://www.jetbrains.com/idea/help/synchronizing-changes-in-gradle-project-and-intellij-idea-project.html
Check this.
You can simply open Gradle tool window at [ View ] - [ Tool Windows ] - [ Gradle ].
In the window, you can refresh by clicking refresh button.
All dependencies manually added directly into build.gradle file will be resolved.
One of the solutions that worked for me after trying everything listed on the internet to solve this issue was to install the lombok plugin.
Got to File --> Settings --> Plugins and look for Lombok.
Make sure the "Enable annotation processing" is ticked
My Gradle project is using Intellij 2019.2.3, and File->Invalid Cache/Restart... doesn't work, but View->Tool Windows->Gradle->sync(the circular icon) works instantly.
In my case, I have to do the following:
close project
close idea
remove .idea project directory
remove (idea.system.path) directory
start idea
You can find your idea.system.path here: https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs
What helped me was checking "dependencies" in "project settings/modules" section. Apparently, Idea did not pick up them correctly.
Steps which worked for me:
delete all modules from "project settings/modules"
refresh the project from Gradle plugin - that triggers generation of modules
This trick helped me to get modules with correct dependencies generated.
Probably it happened because initially, I imported the project as non-Gradle one.
It turns out that the depended packages need to be separately specified in IntelliJ IDEA in addition to build.gradle and explicitly added as a dependency. Namely,
download the com.google.guava package following the instruction in documentation -- I picked com.google.guava:guava-base:r03 to download
follow the automatically-prompted window to add it as a project library to the Java project.
Specify that the Java module depends on the com.google.guava package in the project settings. See the documentation instruction "Configuring Module Dependencies and Libraries".
In my case (Apache Beam sources) a ./gradlew clean was needed.
In My Case, I've Updated the Gradle version(module: project) from 3.2.2 to 3.5.2, and also there was a problem with the NDK file location it was on the wrong path, I've just switched it to the default NDK path, then invalidate and restart the project.
I was having the wrong import.Check if you have right import. In case you have imported using:
import org.junit.Test
and you have org.junit.jupiter.api.Test in class path, try importing with :
import org.junit.jupiter.api.Test;

Categories

Resources