I have created a maven project to implement an example on REST API. To get the values as xml file from a resource which is created by java class, I want to implement an annotation called XmlRootElement which is available in a package javax.xml.bind.annotation. But I was saying like there is no such file called annotation in javax.xml.bind package. Not only this but I don't have some packages to implement such project. Can someone help me?
Related
I created a new Java app from scratch in IntelliJ IDEA. Now I want to use a jar library, e.g. OpenJPA. I added the library using Project Structure -> Libraries like this:
then I tried to use annotations from that library in my Java code, but I don't get the option to import these classes. It looks like IntelliJ IDEA is not known about my library yet:
What am I doing wrong when adding this library? Is there anything more that I have to do to get it working?
After adding this library, it looks like it is automatically added to "Modules":
You have created a library, but you haven't said IntelliJ that the module must use it. Click *ModulesĀµ in the project structure, then select the module you want to add this library to, go to the Dependencies tab, and add the library.
EDIT:
It's simply that the annotation is not part of the jar. You need to add the jpa api jar, not only openjpa.jar
You have to add library to Module dependencies, pls check here:
Configuring Module Dependencies and Libraries
I have a single Maven project that has the "core" and the "web" pieces in it. I'm attempting to convert it into multiple modules.
I've taken the "web" packages and put them into the new project. I've added the core project as a dependency and I can reference its classes within Eclipse. The "core" project correctly shows up in WEB-INF\lib in the "web" project when I build it.
The problem comes when classes from the "core" project are #Autowired in the "web" project.
In this particular case, I'm autowiring a service class from "core" into one of the web service classes in the "web" project. If I add the package that the core service is in to my context:component-scan in my "web" application config, it finds that service, but then the service references a repository, which references an entity, which is looking for an entity manager factory that I've got configured in my application-context in my "core" project.
So it seems that maybe the context:component-scan in the "core" project isn't happening maybe? Or maybe the classes that are picked up are not being made available to the "web" project?
I'm entirely new to multi-module projects, so if anyone can get me started in the right direction to resolve this, I'd greatly appreciate it.
I'm using m2e in Eclipse with the Run Jetty Run plugin if that matters; however, I seem to have the same issues when I do a mvn jetty:run from the command line.
You will need to load the core module application-context from your web module application context. Otherwise it will not be aware of beans defined in the core application context.
Take a look the answers for Application context from other maven module cannot be loaded and Spring import application context from another project for proper solutions.
You can also have a look at this post nicely describing how to create a multi-module Spring project using Maven.
I am trying to figure out how to use external jar in GWT project.
I referred http://www.vogella.com/articles/GWTModules/article.html and it worked perfectly.
But the example explained using another project being included in the GWT project's build path instead of including the jar of that project.
I know this should not make a difference but when I created the jar of the external project (including sources) and used it in the client GWT gave me following error:
The import com.person cannot be resolved
What would be the problem?
For using external gwt library jar file in your gwt eclipse project you have to add that jar file in library tab from java build path:
If you want to use external jar and use that jar classes in your client side. you have to inherit module package entry in client gwt module.gwt.xml
Just example a. com.test.Module2.xml so you have do entry like
<inherits name='com.test.Module2'/>
I'm wanting to use some java code as a reusable component jar in my GWT 2.4 application.
I need access to that code on the client side, so I've read that the steps involved are to
add an entry in the main projects gwt.xml file pointing to this project,
include a gwt.xml file in the jar
and put the java code under a client folder.
I assume that this has to be a gwt project itself, otherwise there would be no need to add the inherits entry or is it not possible to use a regular java project client-side?
Is there anything else I need to do for this (other than ensure the libraries in the jar fall under the JRE Emulation Reference list)?
We don't use the plugin functionality in Eclipse, but to use another project in your GWT project all you need to do is define a .gwt.xml module file in your project that you want to use in your GWT project and reference that module file with <inherits.../> in your main GWT project. You will also obviously need to add that project as a reference in the build path in Eclipse, so you don't get compilation errors. And all of that is besides the fact that your referenced project has to comply to the JRE emulation reference so it can be fully GWT compilable.
I have created a NetBeans module project and need to add a dependency on a JAR file I have created- is this possible? I only see the option to add a dependency on a nother module. I am using NetBeans 6.5.1.
THANKS!
Modules can only depend on other modules.
Create Library that references your class, then create a "Library Wrapper Module" that encapsulates the library as a module.