Installing JPA in Intellij - scala

I have Intellij Idea community Edition and I am programming in Scala.
My #Entity annotations are highlighted with the message "Cannot resolve symbol."
I looked at this question IntelliJ IDEA highlights #Entity class names with "Cannot resolve symbol" in JP QL, which has the same issue.
The answer there says that I should install the JPA plugin for Intellij.
I looked here: https://www.jetbrains.com/idea/help/enabling-jpa-support.html
However, when I search for a plugin called JPA or Java EE in Intellij I can not find anything.
Any idea about why this is happening?
Am I not searching for the correct plugin?

For IDEA to resolve the symbols, you need to add the relevant dependency in the same way you'd add any other dependency. Either (the better option) to your build system (SBT, Gradle, or Maven) or directly to the IDEA project if you don't use any of those:
Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
In the left-hand pane of the dialog, select Modules.
In the pane to the right, select the module of interest.
In the right-hand part of the dialog, on the Module page, select the Dependencies tab.
On the Dependencies tab, click add and select Library.
In the Choose Libraries dialog, click New Library.
If suggested, select:
Java to create a Java library. Select the files and folders to be included in the library in the dialog that opens.
From Maven to download a Java library from a public Maven repository. Specify the artifact to be downloaded and the associated settings in the Download Library from Maven Repository dialog.
In the Configure Library dialog:
Specify the library name.
Select the library level (global, project or module).
Configure the library contents using add, iconLibExclude and delete.
Click OK.
In the Choose Libraries dialog, click Add Selected.
If necessary, select the Export option and change the dependency scope.
Click OK in the Project Structure dialog.
Of course, this won't give you any special JPA support. In particular, the linked question is talking about errors shown in JPQL strings, not on the annotations themselves.

Related

Gluon Mobile: Access JavaDoc from within NetBeans

I would like to access the Javadoc documentation of Gluon using the NetBeans context menu option Show Javadoc:
This fails with Cannot perform Show Javadoc here:
Showing the Javadoc for classes belonging to the Java standard library (for example javafx.scene.Scene) works as expected. Hence, I need to set the url to the Gluon Mobile documentation (http://docs.gluonhq.com/mobile/javadoc) manually. As Gluon projects are managed by Gradle, the project settings dialog appears to have no way of specifying an url. As a workaround I tried setting the url as part of the Javadoc urls for the Java core libs (as I said: workaround) but this did not help either.
As an alternative, I tried downloading the sources from within NetBeans but this did not help, too.
So, the questions boils down to: Where can I specify the url to the Gluon Mobile Javadoc so that NetBeans will pick it up? Thanks in advance.
Gluon Mobile Javadoc is available at the repository with the regular jar (i.e, for the current 3.0.0).
The problem with the gradle plugin for NetBeans is that it doesn't download it.
A possible solution is, according to the plugin author, this one:
For every Gluon project, edit the build.gradle file, and insert this, right after the jfxmobile plugin:
apply plugin: 'idea'
idea.module.downloadJavadoc = true
Save the file, and reload the project (right click on the Project name -> Reload Project).
Now, on the Dependencies folder, right click and select Download Sources.
After a few seconds, the javadoc jar will be added to the project, and you will have the required inline help for Gluon Mobile.

how to add scala-test support to intellij

How do I install scala-test with intellij. The video on the intellij website shows them adding a library dependency with scala-test showing up on the list. I don't have that however as I'll need to install scala-test somehow first. The quickstart on the scala website just seems to have a link to a jar file. Do I configure the IDE in some way to point to that jar file as a global library?
No need for a global library. Intellij IDEA supports adding libraries to your project directly from Maven. Here's how:
Go to File -> Project Structure
Select the Dependencies tab
Click the + sign at the bottom to create a new library
Choose "New Library" and seleect "From Maven" to add a new library from the public Maven repository
This brings up a search dialog which you can use to find the Maven dependency you want. Try searching for "org.scalatest:scalatest" to get the list of scalatest libraries.
To install the latest version of ScalaTest and its dependencies in IntelliJ IDEA 2016.3.2, you need:
Visit http://www.scalatest.org/install (section To include ScalaTest 3.0.1 in your Maven project) to fetch a list of reqiered libraries full names with the following structure {groupId}:{artifactId}:{version}, e.g.
org.scalactic:scalactic_2.11:3.0.1
org.scalatest:scalatest_2.11:3.0.1
Make sure that libraries names contain a Scala version you use in you project, i.e. above libraries are compatible with Scala 2.11 and not working with the new 2.12 version.
Go to File ⇒ Project Structure... or press Ctrl+Alt+Shift+S (Windows):
Go to Project Settings | Modules section and click on Dependencies tab. Then click + ⇒ 2 Library... ⇒ From Maven...:
Type in the full library name to install, then click Search button (or press Shift+Enter), select the library you need and click OK:
Repeat steps 3 and 4 until all dependencies are installed.

JPA Facet cannot be activated in Eclipse

If I try to activate the "JPA Facet" for my Eclipse (Juno) project and point it to a user library containing the JPA libraries (in my case OpenJPA) I get the error:
"The class 'javax.persistence.Entity' is required to be in the selected libraries."
But this class is present there!
"Solution": The JPA libraries were contained in an Eclipse project folder. If I copy it somewhere outside and create another user library with them it works perfectly (although it has exactly the same content as the one before with the libraries located in the Eclipse project!). Seems like an Eclipse bug...
Just create a user library that contains the javax.persistence... JAR in it (It is located in Eclipse/plugins) and add this library at "JPA Implementation"
I'm using Spring Tool Suite (STS). The problem I was facing is that in the default installation the M2E-WTP plugin does not include the Optional component "m2e-wtp - JPA Configurator for WTP".
So I went to Help -> Eclipse Marketplace... and searched "m2e-wtp".
Click on the Installed button and it will become Change. Click on the Change button and select the optional component "m2e-wtp - JPA Configurator for WTP". Apply changes.
This solved for me.

How to Enable the JSF facet in eclipse user library

I'm having troulbe enabling JSF in Eclipse. I have installed the WPT tools that should have had JSF included but when I right click on my project, properties, facets, enable facets I get a warning saying "Further configuration required" I click this, and I'm notified that "At least one user library must be selected" However there are no libraries to select.
I can optionally select "Disable Library Configuration" but I don't know what effects this might have as Eclipse is telling me that i must configure a user library.
Should I download a separate Jar from the Mojarra and add this to my build? Or can I safely disable. Why wasn't it included with WTP like it was supposed to be?
"At least one user library must be selected" However there are no libraries to select.
You have to prepare them yourself by Window > Preferences > Java > Build Path > User Libraries.
I can optionally select "Disable Library Configuration" but I don't know what effects this might have as Eclipse is telling me that i must configure a user library.
When you choose this option, Eclispe will also tell you that the user takes the responsibility of configuring the classpath appropriately via alternate means.
Should I download a separate Jar from the Mojarra and add this to my build? Or can I safely disable.
That's one of the alternative ways. Whether you need to download it yourself depends on the project's target runtime. If it's for example a simple JSP/Servlet container which does not ship with bundled JSF, such as Tomcat 7, then you indeed need to install it yourself. Just dropping the JAR(s) in /WEB-INF/lib is sufficient (or defining it as an user library, of course). Eclipse will automagically do the right things for you (adding to build path, including in exported WAR, etc). However, if it's for example a more full fledged Java EE container, such as Glassfish 3, then you don't need to do anything as it already bundles JSF as part of Java EE API. Just disable the library configuration altogether.
Why wasn't it included with WTP like it was supposed to be?
They have JSF tools included. They do however not include JSF libraries. Or did you read otherwise? If so, where exactly? It must have been a misinformation or misinterpretation.
See also:
JSF 2.0 tutorial with Eclipse and Glassfish
Download javax.faces-2.1.17.jar file and create a new library from manage library option and add the jar file in that library. Click apply, now it will work

Which dependency do I need for this import in Maven

I am trying to convert a Java project which uses Ant into a Maven project, but am having difficulties finding out which dependencies to include.
How do I find out dependency settings for a particular import?
Provided you currently have the jars on your build-path, at least in Eclipse, when you CTRL + click an imported class, and you have selected "link with editor" on the package explorer, the bytecode outline is opened and the file is selected within the jar it is located.
Then, having the m2eclipse plugin, you right-click your pom -> Maven -> Add dependency, and type the name of the jar there. In most cases that would do.
Another vote for jarvana. There are also (that I know of) mvnrepository.com and www.mvnsearch.org
You need to be careful and figure out the correct version of the jar you need. Also, the repos often have many duplicates; different names for what appears to be the same thing, so you need to figure out which one is the "real" one.
How do I find out dependency settings for a particular import?
The easiest way to do that (in a generic way) is to use something like Jarvana, a "Maven-Focused Java Class and Archive Search Engine".
UPDATE: You'll find more search engines in the Frequently Asked Technical Questions that I'm quoting below. I like Jarvana but I don't have any particular recommendation:
How to find dependencies on public Maven repositories?
You could use the following search engines:
http://repository.apache.org
http://www.artifact-repository.org
http://mvnrepository.com
http://www.mvnbrowser.com
http://www.jarvana.com
http://mavensearch.net