I am getting errors in IntelliJ when adding MVN dependency- Selenium Java » 3.141.59. Any suggestions? - selenium

I am getting below errors:
Dependency 'org.seleniumhq.selenium:selenium-java:3.141.59' not found
Dependency 'org.seleniumhq.selenium:selenium-java:3.141.59' not found
Dependency 'org.seleniumhq.selenium:selenium-java:3.141.59' not foundenter image description here

Once any changes are made in pom.xml you must refresh it by clicking on following button (see screenshot).
It will trigger Maven to refresh and download needed dependencies/plugins according to pom.xml file.

Please reload the pom.xml by mentioned in the picture.
right click -> maven -> Reload Project

Related

IntelliJ IDEA not recognizing classes specified in Maven dependencies

import com.app.abc.*;
abc is being displayed in red color.
verified the .m2/repository. dependency is downloaded.
tried reload of project... deleted all dependencies frm .m2 and downloaded again.. Still does not help
even tried mvn -U idea:idea
Also tried
**Right Clicking the pom.xml in Intellij-idea -> Maven - Reload Project.**
Tried File > Invalidate Caches / Restart...
Classes from the dependency are being shown in a list of recommendation by Intellij. But the import statement is causing the error

IntelliJ- Adding testNG maven dependency brings junit

In the POM file when I add the testng dependency, I never get the option to import testng. I only get Junit. I do not have Junit as dependency.
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.3.0</version>
<scope>test</scope>
</dependency>
As I was researching the issue I found someone faced similar issue in the link below. However I did not see a solution. Any one knows how to get around this situation? I want to use TestNG so that I can use testNG.xml to run the tests.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003437720-Why-Intellij-doesn-t-import-the-TestNG-maven-dependency-automatically-
Thanks in advance
It works for me. Make sure you have added dependency for the correct Maven module into dependencies section. After this make sure you have re-imported project in Maven tool window:
Initially I had the same problem when I copy artifacts from https://mvnrepository.com/artifact/org.testng/testng/7.3.0 and paste the code on my IntelliJ it was showing the errors, Once I have Reload from Disk(right click on project it will show the option) it was showing refresh option on the right side of the screen, once I refreshed it the error was resolved.
I tried the reload option shown in the top right corner of Intellij, that didn't work for me. Then I right clicked on project > maven > Reload Project.
After this all the maven dependencies were resolved.

IntelliJ 15, SpringBoot devtools livereload not working

Having issues with the new LiveReload feature with Spring Boot devtools 1.3. It doesn't reload on class changes. I've seen it demo'd with IntelliJ # Devoxx 2015. Is there some IDE setting I need to have enabled? I'm running via the IDE and not through Gradle. I tried enabling "Make project automatically" which doesn't seem to help.
It seems to load correctly and is looking in the correct path
2015-11-23 05:55:30.592 DEBUG 4700 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Starting application com.myapp.Application with URLs [file:/E:/Projects/myapp/build/classes/main/, file:/E:/Projects/myapp/build/resources/main/]
My files
build.gradle
buildscript {
ext {
springBootVersion = '1.3.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
war {
baseName = 'myapp'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-devtools')
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.projectlombok:lombok')
compile('org.springframework.boot:spring-boot-starter-web')
compile('net.sourceforge.jtds:jtds:1.3.1');
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Brixton.M3"
}
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
HelloWorldController
#Controller
public class HelloWorldController {
#RequestMapping("/")
#ResponseBody
String home(){
return "Hello World test";
}
}
if you use IntelliJ IDEA, adding the spring-boot-devtools is not enough. This is because unlike Eclipse, you need to explicitly tell IntelliJ IDEA to “Make The Project” for it to build to the target classpath.
see on youtube
The easiest solution: run app debug mode and press Ctrl + f9 (short-cut for build)
or
You need to enable the “Make project automatically” option. You can
find it in Settings – Build, Execution, Deployment – Compiler
To open the registry, Press Ctrl-Alt-Shift-/ and select "Registry" from the menu that appears, enable the “compiler.automake.allow.when.app.running”
check-box.
To solve this You can do like:
Add LiveReload extension in your browser.
Add devtools dependencies to your pom.xml(if it's maven (spring-boot-devtools)).
In your intellij IDEA go to: file->settings->build,execution,deployment. Go to ->compiler->build project automatically.
In your intellij IDEA: SHIFT+Ctrl+A ->registry-> compiler.automake.allow.when.app.running
I am guessing you are coding and expect DevTools to auto-magically figure out you have changed something in your project? Devtools does that by watching your classpath folder(s). When a .class file (or a resource) has changed, devtools take the appopriate action.
If you don't see anything, that's probably because you're just coding and not updating the classpath. You have to invoke Make Project to update the classpath. See the documentation
In IntelliJ 2021.2 compiler.automake.allow.when.app.running option dissappeared. This option was moved to Advanced settings:
LiveReload and restart are different features. Livereload allows you to detect changes in resources/static folder and notify browser that files changed and the page should be reloaded.
Your question describes Restart scenario. If you want your application to reload automatically on *.class-files changes, make sure your IDE outoputs compiled classes to:
build\classes\main
In Intellij go to Project Structure (Ctrl+Alt+Shift+S) and setup project compiler output dir. After this you can make changes in your classes and press Ctrl+Shift+F9 to recompile current class or hit Ctrl+F9 to recompile the whole project. Spring Boot Devtools will detect changes in build\classes\main and perform restart of your application automatically.
If you want to enable LiveReload for your static assets add the following (otherwise you won't see cahnges of static content while executing bootRun goal):
bootRun {
addResources = true
}
Follow below simple steps, you will be up and running in less than 2 minutes.
Press Ctrl+Shift+A
Search for Registry ...
scroll and find "compiler.automake.allow.when.app.running" then select the checkbox to make it active.
Click close
File Menu -> settings ...
Expand Build, Execution, Deployment
Select Compiler
Select checkbox Build project automatically
Apply
Click Ok
Now stop your application server and then start your application, that's it you will find automatic restart/reload activated when any changes are detected in the project.
Happy Coding/Hacking.
Live reload is a different feature than the problem you have asked the solution for.
In your case as you want to reload your classes after changing them, you need to follow the following 3 steps-
Make change in compiler settings
Make changes in the registry
Make changes in the run/debug configuration
That's it!
After modifying your classes, you can simply press ctrl+F10 to reload the modified classes. You are good to go then!
Addtionally, if you want to configure single point of reload upon modification: https://www.logicbig.com/tutorials/spring-framework/spring-boot/trigger-file.html
For Live Reload:
When a Spring Boot application is running in Intellij IDEA, the templates are served from out/production/resources/templates directory. You can change this behavior and serve the templates directly from src/main/resources/templates directory in development mode. Create a file application-dev.yml in src/main/resources directory and paste the following code snippet in it:
spring:
# Templates reloading during development
thymeleaf:
prefix: file:src/main/resources/templates/
cache: false
# Static resources reloading during development
resources:
static-locations: file:src/main/resources/static/
cache-period: 0
To load the above properties, you need to activate and set the default Spring Boot profile to dev. Add the following property to your application.yml file:
spring:
profiles:
active: dev
Start your application. Now whenever you make any changes in your html files, all you need is to refresh the browser to see the changes!
From the documentation here
As DevTools monitors classpath resources, the only way to trigger a restart is to update the classpath. The way in which you cause the classpath to be updated depends on the IDE that you are using. In Eclipse, saving a modified file will cause the classpath to be updated and trigger a restart. In IntelliJ IDEA, building the project (Build → Make Project) will have the same effect.
intellij 2021.2 has moved this option to AdvancedSettings:
Before anything you need to know devtools is reloading pretty much everything under src/main/ path not the changing to pom.xml file.
1- Add Spring Boot devtools dependency to your maven pom.xml file.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>your-desired-version</version>
</dependency>
2- Restart the project and reload maven.
3- Add live reload extension for your browser from http://livereload.com/extensions/
4- On IntelliJ idea 2021+ under File->Setting->Build, Execution, Deployment->Compiler: check build project automatically
5- On IntelliJ idea 2021+ under File->Setting->Advance Setting: check allow auto-make to start even if developed application is currently running
6- change something under src/main (it could be java code, template, or anything else) other than method signature, parameters, or something like this. For example, change a simple line of your code or change a String literal or some stylesheet in the template.
4- You can skip lines (3-4-5-6) and rebuild the current file by Ctrt+shift+f9 or rebuild the whole project by Ctrl_f9 or if you did the preceding lines and you don't want to even press Ctrt+shift+f9, you don't need to rebuild just enjoy the result on the browser.
5- Enjoy the result on the browser.
For me,
I update to the latest version and in File -> Setting > Advance setting and check
To answer the above question let us first understand a feature in Intellij Idea. You must have seen that the file that you make change need not be saved. And the change that you make in any non .class file remains saved. To cross verify please make some change to the .java file(you can choose any other file as well) and close it and it won't prompt for Saving it and when you reopen the file then your changes are still there.
But if you check the .class file the changes made are not reflected which is obvious because build has not happened.
On the contrary when we enable automatic build in Eclipse it is done on an event and the event is Saving the File -> Ctrl+S(Windows). But in intellij idea that event is not happening or we do not carry out that event.
So, consider the scenario when we do not have spring-boot-devtool then, in that case, we always had to rebuild or restart the server to pick up the changes thereby causing an event.
Now, regarding spring-boot-devtool as Ankush92 rightly mentioned that devtool monitors the classpath changes and restart happens only if there is any change in the classpath.
But as I explained earlier we are just adding our code changes in the non .class file and expecting devtool to trigger a restart even when that change is not reflected in the class path.
Let me mention this again that in eclipse the event to do the same is Saving the File(Ctrl+S) when automatic build is enabled.
So, now the question is how to have a workaround and mimic what Ctrl+S does in Eclipse into the Intellij Idea. It's quite simple lets build the application and the shortcut for that is Ctrl+F9. This will trigger the same effect in intellij as Ctrl+S(in this scenario) in eclipse and help the devtool to find the change in the classpath thereby encouraging it to restart the server. So everytime you make any change in the file and want the server to restart just press Ctr+F9.
I hope this explanation and the workaround helps.
Edit - Macros - Start Macro Recording
File - Save All
Build - Build Project
Edit - Macros - Stop Macro Recording - You can save the macro name as “Save & Make Project”
Preferences - Keymap - Macros
Go down to expand the macros directory to find your newly macro (i.e. “Save & Make Project”).
Double click to Add Keyboard Shortcut and press Cmd+S if you use Mac and Ctrl+S if you use Windows.
Intellij will prompt saying that Ctrl+S already exist just click 'Replace'.
Now all set and Ctrl+S should trigger Spring-Boot Devtools
Reference: https://tomyjaya.github.io/2016/10/08/spring-boot-dev-tools-in-intellij/
In IntelliJ IDEA 2021.2, compiler.automake.allow.when.app.running option is disappeared.
So follow these steps,
File ⇒ Settings ⇒ Build, Execution, Deployment ⇒ Compiler ⇒ Build project automatically
Advanced Settings ⇒ Allow auto-make to start even if developed application is currently running
Add this line to the application.properties file ⇒ spring.devtools.restart.enabled=true
I am using IntelliJ idea 2021.2.2(ultimate edition).
I followed these steps,
File -> Settings -> Build, Execution, Deployment-> Compiler add tick to Build project automatically checkbox
Next,
Press Ctrl+Shift+A
Search for Registry ...
scroll and find "compiler.automake.allow.when.app.running" then I can't find that.
then I reserch about that I find In IntelliJ 2021.2 compiler.automake.allow.when.app.running option dissappeared. This option was moved to Advanced settings:
Advanced settings
I discovered that IntelliJ wasn't even using my Gradle configuration.
Visiting Build, Execution, Deployment > Build Tools > Gradle then under Delegate Settings I selected Build and Run Using and made it Gradle.
Working like a charm
For reference, here is my build configuration:
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
id 'idea'
}
apply plugin: 'io.spring.dependency-management'
group = 'test'
version = '0.0.1'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
}
This works well instead of:
bootRun {
addResources = true // Did not work for me
}
apply the following steps:
Add LiveReload extension in your browser.
link: https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei
Add devtools dependencies to your pom.xml(for maven) or build.gradle (for gradle)
for maven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
for gradle
compileOnly("org.springframework.boot:spring-boot-devtools")
file->settings->build,execution,deployment. Go to ->compiler->build project automatically.
Ctrl+Shift+A ->registry-> compiler.automake.allow.when.app.running
Ctrl+Shift+A ->Edit Configurations->Spring Boot->your application ->
I've been facing this problem a lot on last months on my MAC. Even when following these steps listed here like checking "Make Project Automatically" and "Compiler Automake".
However at my Job, where we use Windows, it works perfectly when I do follow these steps.
The solution for this problem on a MAC I found though is to add a new Run Configuration (Press ⌃⌥R, then press 0) then add a new Maven configuration. On the "Command line" input set "spring-boot:run". Press "Apply" and "Ok" and run the project by selecting the new configuration created.
Of course you could just open a new terminal and just type "mvn spring-boot:run" it will work too.
This worked for me. Add the below line in application.properties file,
spring.devtools.restart.enabled=true
If LiveReload worked for you in the past and then suddenly stops working, and if the other proposed solutions don't work, try uninstalling and reinstalling the LiveReload Browser Plugin. That's what finally fixed it for me.
After finishing all the settings above, you should recompile the html file that you want to reload!
Build → Recompile 'yourHtmlFile.html' (Ctrl+Shift+F9 in Windows)
File -> Settings -> Build, Execution, Deployment-> Compiler
add tick to Build project automatically checkbox
Ctrl+ Shift+alt+/ -> Select registry
add tick to compiler.automate.allow.when.app.running
IntelliJ IDEA > preferences > Tools > Advance Settings > Compiler > check the box to allow auto-make to start even if developed application is currently running.
Add the following dependency on the appropriate pom.xml.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
Make the changes that you want to make while the server is running.
Build > Build Project
Reload the browser
If its Maven and you want dev-tools then check if in your pom.xml, the dependency has been imported by Intelli J properly.
In my case it was showing in red so I did a Maven refresh and that resolved my issue after following other suggestions of Registry from other comments.

In Intellij, right click on a test does not present a "Run" option

In IntelliJ when I right click on a test I dont see a "Run ClassX or MethodY" anymore. In fact there is no "run" window and when I right click I cannot run any class.
It was all working fine about 3 hours ago so I am not quite sure what has changed.
IntelliJ 10.5.1 (Licensed and NOT community edition)
Java 1.6.0_24
This happens for all projects.
Update 1
I installed IDEA 11 and imported settings from 10 and then saw that it was not a free upgrade close IDEA 11 and started using IDEA 10. I am fairly certain things stopped working from that point but not sure. Is that a problem? Can I somehow delete IntelliJ configuration directory somehow and restart?
Adding a screenshot when I don't get Run option on right click:
My problem was that my test class wasn't public. I needed:
public class MyTest {
#Test
public void testMethod() {
instead of:
class MyTest {
#Test
void testMethod() {
If your project is a maven project then you can just right-click on the pom.xml file and select "add as Maven project".
This approach worked for me. (green plus third from the bottom)
I had the same problem. To fix it, I had to ensure that my class had a proper main method:
public static void main(String[] args) {
}
Every keyword in the above statement is critical. If you omit one, IntelliJ wont' recognize it. Easy-to-forget keywords are static, void, and the String[] args argument.
I had forgotten the arguments in mine ;-)
Also make sure your source code is inside a src folder which is marked as such by IntelliJ.
In my case, the cause was disabled JUnit plugin. (File — Settings — Plugins — JUnit, check, OK)
If you're using JUnit 5 (Jupiter), this happens when you use the old #Test annotation from JUnit 4. Just replace
import org.junit.Test;
with
import org.junit.jupiter.api.Test;
and IntelliJ should show the "Run" button again.
Ok after tremendous amount of eyeballing I located a {HOME}/.java directory which seemed to contain some Jetbrains related preferences. I deleted that directory plus {HOME}/.IntelliJ* directories. Then deleted all my intellij installations and downloaded it again from scratch and it now works fine..
Sigh....
Disabling gradle plugin solved the issue for me (community edition 2018.2)
In my case i right clicked the src folder and went to -> mark directory as -> sources root.
I had the same problem. I solve it by
File -> Invalidate Caches / Restart
right click on the top pom.xml -> Maven -> reimport
There should be no need to delete any configuration files.
I found that I used to have the Run option in the context menu to select either run tests or run Scala tests, etc. After I had selected an option for the first time, my options were no longer there.
I was able to resolve this issue and select the type of tests I wanted for that folder by creating a Run/Debug configuration following the instructions found in the documentation here...
https://www.jetbrains.com/help/idea/2016.1/creating-run-debug-configuration-for-tests.html?origin=old_help
As i had the same issue , i could clearly See that #Test is not providing any hint when i press control key and hover , and the same was confirmed as External Libraries was not having Gradle Dependencies added so i had to update the project as gradle project suggested by a pop up when you start Intellij.
I could resolve the issue by disabling the Gradle plugin from the Plugin menu and restart.
If the project is already added as a Maven one, unlink it.
right click on the project -> Maven -> Unlink Maven Projects
Then link it again:
right click on pom.xml -> + Add as Maven Project
I've just had the same problem and solved it in the following way.
Go to your $USER/$INTELLIJ directory e.g. $USER/.IdeaC2018.3 then find config/plugins. Rename the plugins directory and restart IntelliJ.
My guess is that the problem was caused when I upgraded IntelliJ and incompatibilities with the cucumber plugin.
For me this happened after updating Idea, and then updating all Plugins. Apparently Idea had not restarted yet. Going to File -> Settings -> Plugins and clicking 'Restart Idea' solved the problem
if you can see the play button in left side of the main function then click right click and press run.
in my case, I did not have an output folder.
file -> project structure -> under 'project' tab there's 'Project compiler output' -> define your folder.
Unfortunately, none of these worked for me. I had to
'File' -> "Invalidate Caches / Restart"
Click on pom.xml file, and then 'maven' -> "Generate Sources"
Search for pom.xml file --> Right Click on pom.xml --> Click on Add as Maven Project.
You should get a pop-up, saying downloading Mavin Plugin.
Wait till it gets completed. It takes some time depending on the number of content in pom.xml.
In the below screenshot, "BackendApp.java" is Driver Java file that contains
public static void main(String[] args){}
Right Click on such driver java file and you see Run option in green color.
I had this problem with a Kotlin project. Following action solved it:
right click on test folder -> select Mark Directory as -> choose Test Sources Root
So I had this problem on pycharm and the problem was that there was already a run configuration (in the dropdown next to the play button) that had the name of the file. When i deleted that run configuration it would create a new one that was correct.
I had the same problem and I tried all the above solutions nothing worked for me but after I install TestNG plugin it's started working since there are some TestNG annotations used in my unit tests
I had the same problem on my Intellij 2019.3 after that I updated from 2019.2.4. I thought that the problem came from the updated first, but the rollback didn't fix, so I tried de solution above e the problem was fixed. After configuring all my projects from scratch the problem get back, so I started to check everything I did. I discovered that an old project from Eclipse that uses files .launch to run and need some plugins to be able to execute on Intellij was causing the problem, after disable the following plugins the test option return.
In my case, my project is using Bazel.
The solution was to sync Bazel from Bazel plugin.
Since this is a top Google result when trying to figure out how to run a Scala project, and since for some reason IntelliJ (I'm on 2020.1.2) doesn't automatically create a run configuration for a Scala project (in contrary to a Java project), it's worth laying out the basics for future readers:
Click on "Edit Configuration" on the top right of the screen.
Inside the opened window, click the + button its top left.
Choose "Application".
Now, let's go through the required fields:
in the "Name" field, enter a name for this configuration, e.g. "run".
in the "Main Class" field, enter your main class name.
Alternatively, use the ... button to the left: inside the window that opens, click the "Project" tab, navigate to your main class, pick it and click "ok".
Note: If your main class doesn't have a main method, IntelliJ would show an alert. see listing 9 below.
Make sure the value in "Working Directory" field is correct (it should be the project folder).
in "Use classpath of module", select your module (see project vs module in IntelliJ)
That's it for configuring. Click "Apply", and close the window. Here's an example final result:
Note that my Main class is part of a package named Demo, but having a package is not necessary.
Inside the main class, make sure there's a main method.
See #Josiah Yoder answer for java, and for Scala it's:
def main(args: Array[String]): Unit = {
}
That's it. You should now have the green run and debug buttons enabled.
Seems there are version conflicts between plugins and IDEA itself that commonly break this functionality. Many of the solution here indicate people manually trying to identify the plug in, I found that to be impossible. So here is a generic way, without having to uninstall IDEA as one solution proposed:
File > Settings > Plugins > gear icon > disable all downloaded plugins
This fixed it for me.
Make sure the method is not static! JUnit only allows #Test before instance methods but Intellij doesn't complain even if you use #Test above a static method.

Resolving maven dependencies

Inovking maven2 goal mvn dependency:list on an artifact pom causes to download the whole dependent artifact packages. I think only those pom files are necessary for resolving dependencies. Aren't they?
On the dependecy plugin documentation you can read that dependency:list is an alias for dependency:resolve. What you need is dependency:tree which :
Displays the dependency tree for this project.
Even with dependency:tree you will have to download dependencies.
From Arnaud Héritier (developer on Maven Project)
This is a problem in maven core which doesn't allow in 2.x to resolve dependencies without downloading artifacts.
Each mojo (plug-in in the Apache Maven) has a functionality description. See all dependency plugin functionality.
I am working with the current edition of Maven (the plug-in that shipped with Eclipse Neon), and I'm still working to get my head around how to make it do all the magical things it is claimed to be able to do.
I have the screen pictured below, in which the dependency highlighted in the left pane is unresolved.
!Dependency tree, showing missing dependency1
I thought that selecting (executing) the Update Project item off the project's context menu, as shown in the following image, would resolve it, but it left me with three errors, all, one way or another, the result of a missing dependency.
!Maven fly-out menu in project context menu2
By examining the file system, I have confirmed that the dependency is, in fact, absent.
Color me confused; why didn't that action download the missing dependency?