0

I open the project by IntelliJ IDEA, the project is created by eclipse, and I have refreshed my maven, and downloaded the sources.

Why I still get so much red wave line under my every dependencies?

enter image description here

Some one know how to solve that?

Community
  • 1
  • 1
s-n-2
  • 405
  • 1
  • 6
  • 24
  • What does it say when you hover over it? – Dave Newton Apr 26 '17 at 14:47
  • 1
    "red lines" usually have error messages that belong to them. Without those messages it is almost impossible to tell what the exact problem is. – OH GOD SPIDERS Apr 26 '17 at 14:48
  • 1
    It looks like you need to reimport your project. If you've done that and you still have the red lines try maven in a shell -- cd to your project root and type `mvn clean install`. Then take a look in the `~/.m2/repository` folder to see if it's full of interesting things, like junit. Once you've run mvn from a shell, try reimporting into idea. Finally, close your project and choose 'open', then select your project's root pom, then tell intellij to create a new project and not reuse anything from the old one. – Software Engineer Apr 26 '17 at 14:51
  • @EngineerDollery How to do with that? – s-n-2 Apr 26 '17 at 14:55
  • So by "refreshing my Maven" you mean? Usually you also have to re build your project in order to dependencies to be found – DarkCygnus Apr 26 '17 at 14:56
  • @GrayCygnus Can not find most lib of maven, some can find . – s-n-2 Apr 26 '17 at 14:58
  • @EngineerDollery when I cd in the root of my project, then use `mvn clean all`, I get the error:`-bash: mvn: command not found` – s-n-2 Apr 26 '17 at 15:00
  • Are you sure you added all the dependencies you need (and the correct version) in your file? – DarkCygnus Apr 26 '17 at 15:00
  • @DaveNewton Shows nothing. – s-n-2 Apr 26 '17 at 15:01
  • @s-n-2 -- install docker-machine, then in the docker bash shell, change to your project root and run `docker run -it --rm -v /`pwd`:/work -w /work maven bash`. Then run mvn clean install. – Software Engineer Apr 26 '17 at 15:49
  • @EngineerDollery That seems a pretty extreme solution for a Maven dependency issue. – Dave Newton Apr 26 '17 at 16:59
  • See http://stackoverflow.com/a/42427510/104891 – CrazyCoder Apr 26 '17 at 17:21
  • @DaveNewton -- I wouldn't call docker extreme. It's rather simple to use for development in this way, as long as you're told how to use it. It's not like I'm asking the OP to build a fully automated dynamically scaled software development pipeline with fully containerised copies of the production environment. I just want to see what happens with a standardised environment and this pom. – Software Engineer Apr 26 '17 at 20:23
  • It'll work fine--it's not a Maven issue, it's an IDE issue. If he ran it from the command line it'd be fine. – Dave Newton Apr 26 '17 at 20:25
  • @DaveNewton -- how do you know? (personally I think the OP doesn't know how to use maven and has made everything a system dependency but the libs aren't where the pom points to -- answer, remove all system dependencies). – Software Engineer Apr 26 '17 at 21:27
  • @EngineerDollery Because it's an IDE/project configuration issue, delta the potential issue at the top of their pom. Which would be made obvious by running it from the command line, no VM or clean-room required. – Dave Newton Apr 26 '17 at 21:36
  • but they don't have it installed... – Software Engineer Apr 26 '17 at 22:16

2 Answers2

0

Intellij may have a problem getting dependencies from your Maven repository due to a certificate. If you are using Artifactory, and the URL starts with HTTPS, you may need to add the certificate to Intellij's truststore.

Here are the steps:

In a terminal:

openssl s_client -showcerts -servername <hostname> -connect <hostname>:443 </dev/null

Copy the lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE----- into a file called artifactory.cert.

Then, in the terminal:

keytool -import -file artifactory.cert -alias artifactory -keystore C:\truststores\intellij.truststore.jks

When it prompts for the password, enter a password.

In Intellij, choose Help > Edit Custom VM Options (it may prompt you to create the file the first time).

Add the following JVM arguments:

-Djavax.net.ssl.trustStore=C:\truststores\intellij.truststore.jks
-Djavax.net.ssl.trustStorePassword=<the password you created above>

If things still do not work, try closing the project, deleting the project's .idea directory, and opening the project.

Tony Zampogna
  • 1,928
  • 1
  • 12
  • 14
-1

First I can not recommend to use <scope>system</scope> dependencies. Always try to prevent them cause it shows that you didn't understand the concept of Maven by using dependencies which are automatically handled which means downloaded either from Maven Central or from a corporate repository manager.

If you do you use them than use them correct which means like this:

  <dependencies>
    <dependency>
       <groupId>..</groupId>
       <artifactId>..</artifactId>
       <version>..</version>
       <scope>system</scope>
       <systemPath>...</systemPath>
    </dependency>
    ...
  </dependencies>

The problem is that you have same parts of that somewhere else in the pom.xml file where it not belongs...

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • despite your excellent rep, I don't think you read the question properly. I really don't think that his problem is a single errant system dependency. – Software Engineer Apr 26 '17 at 20:20
  • You can of course think that way but a pom file has a defined XSD and if this is not fulfilled the IDE can't read that correctly which means it can't be interpreted correctly which results in errors. So I would suggest to first fix the problems and afterwards we see further. Apart from that I would always suggest to check the build on command line first and if this is Ok than go a step further to an IDE... – khmarbaise Apr 26 '17 at 21:05
  • I can see systemPath in the code -- I think the hover-over could be obscuring the one you're referring to. – Software Engineer Apr 26 '17 at 21:24