Intellij package does not exist - java

IntelliJ 2022.3.2 Ultimate
MacOS (latest)
Stumped ...
Project A builds fine, installs jar file in local repo, ~/.m2/repository/...
Project B has a dependency on Project A. Looks like it's there in Maven -> Dependencies.
Project B does not compile, "package ? does not exist".
I manually copy the jar to ./lib and add it in the module dependencies for Project B. Again, Maven -> dependencies lists the jar file.
Inside the jar file in BOOT-INF/classes/... the class files are there.
IntelliJ does not recognize the jar file, no matter what I do. Basic stuff here. I've tried all tricks except the one that fixes the problem. I've changed the java version to 11 from 17. Used maven compiler plugin with source and target set to 11. Disabled additional IntelliJ plugins I had installed. Nothing in idea.log that stands out. Project B simply can't find the jar for Project A.
Project A and Project B are spring boot projects. I've done local dependencies before and everything has worked fine, except in this case.
TIA,
Eric

Related

Intellij: Java 11: export module: package not found {module not found}, module-info.java

I'm trying to create a simple modular programming application.
My project consists of two modules-
com.module.model
com.module.util
when I'm trying to export the module com.module.model in module-info.java.
IntelliJ cannot find the package to import.
(However it should give me the error of module not found)
The same problem stands for 'requires module' too.
I have provided all the modules in the dependencies for com.module.model
Solutions I already tried-
Build the modules separately (before adding the export line) and the whole project (maven clean install) as whole.
Invalidated caches and restarted.
SDK and Language level is set to 11.
You need to create those packages com.module.model and the like within the java folder of your IntelliJ project.
Within IntelliJ, the directory that you've named as com.module.model is the "IntelliJ module" name and has no relation with the "Java module system", in that you would be using the artifact generated out of this project.
To add a screenshot on the similar lines as of the question. It would look like:

Unable to import the Maven module in Intellij

I am trying to open this module in Intellij:
https://github.com/eugenp/tutorials/tree/master/javaxval
The steps followed by me:
Go to required directory javaxval/ in my local and
mvn clean install.
Open the pom.xml inside javaxval/ and open it as a project.
But Intellij is not syncing with the libraries mentioned in pom.xml as I can see in libraries section in Project Structure settings. Also, because of that, I can see lot of compilation errors.
Any idea what is the issue I am facing and how can I fix it?
This project imports and builds fine in IntelliJ IDEA 2019.2.2 version using the bundled Maven 3.6.1 for importing and JDK 1.8.
If it doesn't import/build for you, perform the diagnostics and check the logs as described in this answer. Make sure the parent pom file is present in the directory tree on your disk.

Not able to get directory structure and Maven dependencies

I have checked out a Maven project from Subversion. It has Java with Spring framework and Groovy.
We are using Groovy Eclipse compiler plugin. On Maven install, code compiles perfectly with Groovy Eclipse compiler and a jar is created in target.
But there is no directory structure which is usually created in Maven. No classpath too.
I tried many things nothing worked. Finally I converted project to faceted form and then src/java was created as it was faceted to Java project. Still no Maven dependencies.
As there was no Maven dependencies, many jars were missing, so I added jars to build path manually. I also added src/groovy to build path and then it was not able to compile Groovy classes, so I configured project as Groovy project and DDSL was generated. Now after so many manual settings, it is not working fine when it has to create object using spring for Maven class.
I tried a project without Spring framework, and it worked fine.
For pom.xml: I have referred: http://docs.groovy-lang.org/latest/html/documentation/tools-groovyeclipse.html.

GWT maven project compiles and run from maven but don't compile and run in eclipse

I have multi module maven project, that is build with gwt as a main web framework. Here is github repo.
Everythink works as it should as I supose. I haven't got anything wrong.
Unfortunatelly the problems occur when I try to import this project into eclipse (as maven project). I can not compile this project (using RMB on project in Package Explorer -> Google -> GWT Compile).
I am getting an error:
Loading inherited module 'src.main.resources.pl.derp.parent'
Loading inherited module 'pl.derp.shared'
[ERROR] Unable to find 'pl/derp/shared.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
When I tried to RMB on Project name in Package Explorer -> Run -> Run as Web application (GWT Super Dev Mode)
I've got:
Working directory does not exist: /home/danielo/eclipseGwt/gwt_2.7.0_maven_eclipse/web/src/main/webapp
I've added modules to build path.
I've followed this instruction
I think, that I've done everything to make it work, but still can make it work.
I think the problem is in packages name, and the way they are treated by maven and eclipse. They are treated in diferent ways.
Maven easily find every class (f.e.: package pl.derp.web;) needed and compile. The eclipse is trying to find them by f.e.: src.main.java.pl.derp.web but can't found it.
Really I don't know how to resolve this issue?
I am not sure witch package name patter is better (src.main.java.pl.derp.server or pl.derp.server)- for me the shorter is better.
To run this project in maven (it is well described here):
mvn clean install
mvn tomcat7:run-war-only
and in second shell:
mvn gwt:run -pl web
And in Eclipse I think I am running built in Jetty server
Please give me some help.
You apparently have a single Eclipse project, with server, shared, and web declared as source directories. When using M2Eclipse, you should have 3 projects, each with their src/{main,test}/{java,resources} declared as source directories. At a minimum, without M2Eclipse, the source directories must be the src/{main,test}/{java,resources}, whether you have 1 or 3 projects.
This is why Eclipse looks for src.main.java.pl.derp.server instead of pl.derp.server, and why GWT fails too (classpath is similarly wrong).

Maven missing classes

I created a basic maven project in eclipse and I'm getting errors in my pom.xml that classes are missing, I checked the folder that it was looking in and the file paths don't match what I have and the classes don't exist.. My path goes up to: C:\Users\user.m2\repository\org\apache\maven\shared and it is stating there is a /filtering/ folder which I don't have. I have the latest maven and m2eclipse installed.
Most probably a bad installations (incomplete download or missing jars). I suggest you delete the
C:\Users\user.m2\
folder completely and run mvn clean install again. Maven will fetch the jars for you. Also try to refresh the maven project from within eclipse. Right click on project -> maven -> update project. Sometimes eclipse has this issue.

Categories

Resources