I followed dropwizard tutorial and build a simple API project( or maybe I should call it a module). Can I make it a module? Since there is a main method in it, is it allowed to have main method, pom.xml and yml file in a module? If so, when import several modules to a project, how to use the service it provides?
What is the folder structure difference between a project and a module? I notice in the Project Settings of Intellij, I can either add my application to the module, or artifacts.
Should I package my restful API project as a jar to use it?
1.
A project can contain one or more related modules.Each module is a separate library, application and can be a jar, ear or war.Also modules aren't just Java either. You can have modules for ruby, scala, or something else as well.A project is a convenient way to develop related, interdependent applications, libraries in concert.2. Module folders are subfolders of the project folder. An artifact is an assembly of your project assets that you put together to test, deploy or distribute your software solution or its part.see https://www.jetbrains.com/help/idea/working-with-artifacts.html
3. Your REST API most likely will be a web app. So it should be a war/ear.for a sample see https://www.jetbrains.com/help/idea/creating-and-running-your-first-restful-web-service.html
Related
I have a simple project with following structure:
myApp - parent pom
|-app - REST API module
|-db - JDBI module
I want these two to stay as they are and add a third module from which I will be able to create a war. Also, my app module is a REST API created using Dropwizard. I read that I should create in new module a WEBINF catalog with web.xml, but I don't know what do I put in there.
Are there any example projects, tutorials, links or references how to do it? I'm new to maven and Java EE.
I found what I was looking for. It's wizard-in-a-box project that do all the necessary things to build a WAR file.
I'm using Google App Engine to create a project consisting of multiple Google Modules. How do I set up my project (using Maven) so that I can share source code such as Objectify object model definitions, shared utility code, and unit test code across the modules?
I'm hoping the answer is simple and that I can just use Maven as suggested in answers such as these:
How do you use Maven to share source code for two projects?
How to create shared source folder across multiple projects in Eclipse?
For test code: Sharing src/test classes between modules in a multi-module maven project
For test code: Share test resources between maven projects
Eclipse Linked Resources: https://stackoverflow.com/a/7585095/2848676. Is this compatible with Maven though?
However, I'm concerned there might be something special about Google App Engine modules that makes them different from Maven modules. And then maybe the approaches above won't work.
As an example of why I'm concerned, notice that Google says "Although Java EE supports WAR files, module configuration uses unpacked WAR directories only." yet some of the solutions given above suggest packaging the shared code into JAR files. I realize WAR and JAR are different but I'm worried I'll waste my time trying to make something work that can't.
Any advice on how to share code among Google App Engine modules?
I have a share directory that contains code I want to share between modules.
Then I can make symlinks from my modules directories to the share directory.
The symlinks can be of a file, sub-directory, or the whole share directory itself.
I have a Ear Project which includes two Appengine Dynamic Web Project and one shared java project (which has common classes).
I have added shared java project to EarContent Folder through Deployment assembly settings in EAR Project and i can see the java project jar file in published folder under EarContent folder.
Now i wanted to use the Ear library in Dynamic Web Project, so i have added this library in MANIFEST.MF setting for both the project and at compile time i can access the class from shared project too.
The problem is when i publish it, i couldn't able to find the java project jar in Both Web Project, i have tried almost every settings but nothing was helpful.
Am using Eclipse Mars, AppEngine SDK version 1.9.10,
Does any one tried this, is there any possible solution for my problem. any thoughts or suggestion is highly appreciated.
Thanks!
It looks like the Google Plugin for Eclipse doesn't recognize anything in EarContent/lib (or whatever your EAR library path is) regardless of settings when packaging the WAR files for each Dynamic Web Project. The JARs need to be physically present in WEB-INF/lib for each Dynamic Web Project in order for the modules to deploy properly.
I would recommend opening a feature request in the official issue tracker here:
https://code.google.com/p/googleappengine/wiki/FilingIssues
I am writing an application that integrates Geoserver with a custom component, intended to be hosted on a single servlet engine. Both are Maven based projects, and I would like to stay in Maven land to package it all into a nice distributable. The general idea I have is to add another module to my application that packages the application itself, Geoserver and all dependencies into one nice archive.
I am aware of the maven-assembly-plugin and its capability of storing all dependencies in a target folder, but I am not sure what would be the best way to create a package that it easy to deploy. Googling for any examples has not been successful.
Extra bonus points if the module can be started via mvn jetty:run.
Have you considered packaging them into an EAR project. It will bundle a set of WARs (and jars), and allows you to specify or generate a deployment descriptor.
So I started with a web services project (just a dynamic web project) that builds and debugs correctly from eclipse. We've pulled a chunk of common code out that we want to put into a shared library so now those classes are going into a separate jar project that the web project references.
On the web project, I did Project->Properties->Java Build Path->Projects->Add and added the jar project. And this correctly solved all the compile-time classpath problems and everything builds fine. But at runtime, when the tomcat server fires up, spring attempts to inject some of the classes contained in the jar file and I get a NoClassDefFoundError.
My .class and properties files and the contents of my META-INF directory are showing up in the ./build directory, but my WEB-INF/lib directory seems to be referenced in-place, and the jar dependency doesn't get copied in to it to show up as part of the Web App Library.
What is the magical incantation to tell eclipse that the other jar project needs to be available to tomcat at runtime? From our ant build script, we first just build the other project into WEB-INF/lib and everything works fine, but not for eclipse debugging.
I figured this out after spending some time on it. If you are in Eclipse Helios , go to properties > deployment assembly > add > project and select the dependent project you wish to add.
Java EE module dependencies would solve this problem.
You have already done the task of extracting your common classes into its own project, possibly because other projects depend on these classes. Either way, you'll have to ensure that this is a Utility project (appears under Java EE in the project wizards), and not just a plain Java project.
One that is done, you can proceed to add the Utility project to your build path (compile-time path) as you have figured out.
The additional (final) step is to establish a Java EE module dependency between your Dynamic Web project and the shared library, which causes the utility's classes to be placed in WEB-INF\lib during deployment, and even during export of the WAR. To do so, visit the dynamic web project's properties, and browse to the Java EE module dependencies. Ensure that your utility project is selected here. Redeploy/publish your application and you should be good to go.