Proper way to generate Javadoc in Spring Boot apps? - java

I am new to generating javadoc and confused about the following issues with javadoc generation in Spring Boot apps:
Should I add class definition to each class in the application? Could you give a definition example for Controller classes?
I am using IntelliJ Tools > Generate Javadoc menu with the default choices and choose javadoc directory in the resources folder. Is there a better way for generating javadoc and keeping them in a Spring Boot app (I use resources/javadoc folder, but not sure if there is a proper way as a convention for this).

we just use swagger
visit locol like:
http://localhost:8080/swagger-ui.html

Related

Dynamically adding beans and jars to Java application

For an ongoing project, we are looking for a possibility to dynamically download and load jar files into a running application. Apart from downloading the files (which is probably fairly straightforward), I am unaware of any solution that would automatically add the jar's to the classpath, and do discovery of the annotations (like CDI beans).
Given such a system, it would be rather handy if the #Inject annotation would not throw a runtime failure of an implementation of a class is not present (because that module-jar was not loaded).
Is there currently any such system? Does spring or OSGi fit this need?
Any ideas how close project Jigsaw would come in trying to fulfill this on application level?
I think you need OSGI, using an OSGI container like Karaf : https://karaf.apache.org
In standard java provide ServiceLoader https://docs.oracle.com/javase/tutorial/ext/basics/spi.html
I advice you to not follow that path
It should be possible to dynamically load jar files without the usage of OGSI. The keyword are Classloaders especially when used with a proper hierarchy. The following answer should give you an idea: How should I load Jars dynamically at runtime? but keep in mind that this might cause serious security issues
You followed the path at 2. even I advice you not to do it. But now you end up in the scenario that the context of your used framework does not know this classes. You would have this problem with most IOC frameworks. Since they build up the context on startup. There are libraries for this created for development purpose (spring-loaded, spring dev tools, JRebel). If your IOC framework supports it go with it.
Regarding handling not available jars. The best point to do research on this is Spring Boot and its auto configuration mechanism. It checks if certain classes/jars (not sure to be honest) are available and add additional behavior for this cases. But still this is application startup solution and not a runtime IOC solution.

Swagger + javadoc generation tools (swagger-jaxrs-doclet , swagger-core) don't work in OSGI environment

There are no usage steps for non-maven projects and very little documentation on how it should be used. What are the appropriate steps for using any of those tools?
You can take a look at this page: http://amdatu.org/components/web.html
It describes how to setup REST endpoints in OSGi and dynamically expose them in Swagger (bundles for Swagger itself are also included). That's as close to a guide on this that I know.

Java Web Application. Spring Boot. Locating Images

I've recently solved a problem of locating images in this community. You can look here.
However, one answer said:
Your app is a Spring Boot app. I think that you can also try to use the facilities provided by Spring Boot for serving static content. Anyway, you are doing it right now because you are using webjars for css and js libs!!! Be consistent with the tech that you are using.
This means, it's recommendable to locate the images files in /src/main/resources and not in /src/main/webapp.
How could i use the facilites that Spring Boot provides me?
Thanks
Spring Boot automatically configures production-ready settings and adds beans to your Spring project based on some dependencies that are declared in your maven/gradle build file. As long as you follow the conventions, then you do not have to do so much configuration -- "convention over configuration". For example, one convention is to load your images and static files in the resource classpath. Refer to the documentation: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/

Pre-Configured Java Web Application Project

Everytime when I create a new java web project, I have to configure and add many folders and property files for primefaces, hibernate, jsf, ldap, tomcat etc.
It wastes all my time. I find a solution for this, but it is not a generic solution.
My solution is that, I created a web project and configure all props and folders but not develop any code. It was an configured empty project. I mean it was my custom template project.
When I want to create a new web project, I always have to import this configured project and rename it. It's not a good way I think.
So, In the project creation tab, how can I add my custom project to creation wizard or how can I create my custom project in the beginning.
Is there any plugin or tool to create pre-configured template web project ?
Is there any tutorial to develop an eclipse plugin to do this ?
Thanks for your interest.
You probably need e.g. maven archetype that would generate such a project.
Alternatively you can use Spring Tool Suite, it has some predefined templates.
If you want to create plugin by yourself you can read more about Creating Eclipse Wizards (by Lars Vogel). But this is not so trivial (may need some work to make it work perfectly). Generally whole Lars Vogel's site is about creating Eclipse plugins.

How to find Spring XML definition from Java Class in Eclipse

I work on a large Spring/Struts project in Eclipse. One thing I have to do frequently is dig through the spring.xml file so that I can update the definition for the class that I am working on. It seems like there should be an easy 2 or 3 click way to go from the Java class I am in to the Spring definition.
I have SpringSource installed, but this doesn't seem to offer anything that's actually useful to me. Does anyone know if this is possible in Eclipse and how to do it?
Bonus Question: is it possible to jump from a Struts Action class to it's corresponding struts.xml definition in Eclipse?
in your eclipse project, just add the spring nature. Right click the project and select the Spring Tools option -> Add Spring Nature. This will ensure eclipse keeps your java classes and spring context in synch.

Categories