Reputation: 1863
I'm new to JAXB and am using IntelliJ. I'm following an online tutorial. At the point where I'm learning to Marshall / UnMarshall, I have downloaded the source code. Within the Marshalling example class, I am trying to import a stub that has been auto generated but IntelliJ does not recognise the import of the Patient.class when trying to use it as a parameter to JAXBContext.newInstance(Patient.class):
I have tried invalidate caches and re-start. The demo uses Eclipse. I notice a .classpath file in the demo that is not auto generated when I try with new project in IntelliJ.
Thanks
New screenshot following suggested solution:
Upvotes: 0
Views: 354
Reputation: 729
This happens because the root source code directory in your project is src/main/java
and the generated classes are in src/generated/com...
. You can either set your src/generated
directory as source directory, by right click -> Mark Directory as -> Source root.
Or you can move the generated classes under src/main/java/com...
. I suggest to do this second option.
Edit after the new question:
So you are using jaxb2 to generate those classes. I think you should set it like this: <generateDirectory>${project.basedir}/src/main/java</generateDirectory>
without the generated
folder in the path. Since the package name in your classes starts with com.bharatthippireddy...
and not with generated.com.bharatthippireddy...
therefore in the source root directory there must be the com
folder. I think it should work even if there is the META-INF
and org
tree. I do not know how can you omit the generation of those trees, may be the JAXB2 documentation contains some clues.
Upvotes: 2