I have found similar Stack Overflow posts for configuring Swagger + SwaggerUI + Jersey, but almost all of these use Spring and I have not been able to find a solution for what I am trying to do.
I have Swagger + Jersey working, and have copied the swagger-ui/dist folder from: https://github.com/swagger-api/swagger-ui to my webapp directory, and have edited swagger-ui/dist/index.html file to point to my swagger.json output. I can properly access Swagger UI at http://localhost:{port}/{base-path}/dist/index.html
However, I do not want to have to copy the pre-build dist files to my webapp directory every time I need to fetch updates. I would like to automate this with Maven (which I am new to as well as Jersey/Swagger), and found this dependency online: https://mvnrepository.com/artifact/org.webjars/swagger-ui/2.0.12
However, I do not understand how to configure the path from my webserver to this webjar dependency.
To recap, I have Swagger UI working on my local machine, but only by manually copying the pre-build files to my webapp directory and would like some way to automate this (I have found solutions using Spring, but I am not using this).
Related
I was trying to update my Jhipster 4.0 project (which used Angular 4) to Jhipster 6.0 (which used Angular 9). There was such a difference in the Angular version and Typescript version, that I instead just created a Jhipster 6.0 project, and then I replaced all of the following files in this Jhipster 6.0 project. These files were replaced with the files from the Jhipster 4.0 project, so I could get the front-end working again - src/main/webapp - src/test - package.json - webpack - tsconfig.json
In essence this makes it use angular 4 again ... makes it use the old typescript ... and lets it have all of the old front-end code. I can bring the application app just fine (using ./mvnw and npm start). But only http://localhost:9061
I'm attempting to serve the old angular code through port 8080. Currently only the index.html file gets served there, and it is the nearly empty html file with a jhipster needle.
When I attempt other url paths, this page is still served up.
For example, the following urls both serve up the root index.html file:
http://localhost:8080/#/dashboard
http://localhost:8080/app/dashboard
But, if I try to serve up static content from similar urls, that does work. For example, this does return the .css file correctly:
http://localhost:8080/app/dashboard/dashboard.css
So, in short, I'm trying to find a way to serve up slightly older Angular (v4) from an updated JHipster app, but the angular components are not being served. Thanks!
Make sure you have this in your webpack.dev.js - contentBase: './target/classes/static', ... and that you do NOT have this - contentBase: './target/www',
I am deploy an project Spring Boot, using devtools(spring-boot-devtools) and call a Soap service.
I generate the Soap class into /src/main/resources/templates/generated
and add this folder as Source Code.
Because when call this Soap service, its have a problem:
java.lang.IllegalArgumentException: ...ClassV11PortType referenced from a method is not visible from class loader
So, I was add the spring-devtools.properties file to /src/main/resources/META-INF/spring-devtools.properties
and add this line to spring-devtools.properties file:
restart.exclude.mygeneratedclasses=/[packageOfGeneratedClass].class
Then now, I can call the SOAP service successful.
But now, my project cannot reload automatically when i modified some code.
I was try to edit some code anywhere and save but not luck, my project doesnot reload.
Instead of excluding generated files, you can try to include JAR responsible for loading these classes into restart classloader (used in spring-devtools).
For dependency com.sun.xml.ws:jaxws-rt:2.3.2-1, update /src/main/resources/META-INF/spring-devtools.properties like this:
restart.include.jax=/jaxws-rt.*\.jar
Github issue reference: Devtools cannot be use with jaxws-ri #19379
Sorry if this is a duplicate, I looked at several other questions but none seemed to match or provide workable solutions.
Problem
I am writing a Spring Boot (v2.0.2) app, this app exposes a RESTful API which then calls into a WSDL service. I've generated the WSDL classes with Maven/jaxb plugin and everything works from my dev machine. When deployed to the server I get an error that the WSDL service class can not load the underlying WSDL file. The problem is that when the Java classes are generated it is using the full path from my dev machine (snippet from the generated service class)
try {
URL baseUrl;
baseUrl = com.mytest.WSDLService.class.getResource(".");
url = new URL(baseUrl, "/home/users/me/projects/wsdltest/wsdl/MyWSDL.wsdl");
} catch (MalformedURLException e) {
The WSDL file (MyWSDL.wsdl) is in the spring boot JAR file for my application, it is in a subdirectory off root called 'wsdl'
Question Is there a way that I can load this WSDL from the JAR file without having to modify the generated classes?
Ideal Solution I'm hoping to find a solution that doesn't make me modify the generated files (we intend to do this for several services), ideally I'd like a solution which can be done at build time (in the pom.xml?), if that's possible.
Solutions Tried
A post on here suggested using the "wsdlLocation" tag in my pom.xml and provide a explicit path to the WSDL file, e.g. <wsdlLocation>/wsdl/MyWSDL.wsdl</wsdlLocation>
Tried most of the solutions from this thread
Thanks in advance
I think I was able to find a solution thanks to this SO Thread. Evidently the answer depends on the version of the jaxws tool being used in maven (jaxws-maven-plugin). The project (which I inherited) explicitly asked for version 1.12 (which invoked JAX-WS RI 2.1.7-b01-), using this version of the tools I was able to use the '<wsdlLocation>classpath:wsdl/MyWSDL.wsdl</wsdlLocation>' solution in the thread mentioned. Once I noticed that the pom was using an explicit version I removed that the jaxws was updated (using JAX-WS RI 2.2.10) but then the 'classpath' solution stopped working. I switched to the other option mentioned in the thread '<wsdlLocation>/wsdl/MyWSDL.wsdl</wsdlLocation>'
I did a quick test and this seemed to have solved the problem (in both my dev machine and my test site).
Thank you
I'm learning to make Java MVC project using Spring Tool Suite tool.
The path to make new project is:
File->New->SpringLegacyProject->Spring MVC Project.
My question is: which directory I have to use to add additional not-Spring files and where and what do I have to type for Spring files to see them?
For example:
css files - where to put and how to make jsp views see them, will 'link rel="" 'tag be enough?
properties files used to specify database connection or to specify messages for ReloadableResourceBundleMessageSource. In this case, do I have to create bean for this class in root-context.xml?
Thanks.
You should probably use Spring Boot (i.e. use File->New->Spring Starter Project and select Web as a starter. Place your web resources under src/main/resources/static folder. They are picked up automatically from that folder.
You should try an example project: File -> New -> Import Spring Getting Started Content and then pick "Serving Web Content" from the list.
Try some DB getting started content example to get the answer for the second part of your question.
I'm in the process of migrating my project as a spring boot application (mostly for the embedded tomcat solution) from a WAR that was previously deployed on tomcat.
So I encountered a problem with the embedded tomcat container that I hope someone can perhaps offer a solution, perhaps through spring or maven instead of modifying my dependency jars that my project uses to work around this issue.
I have two data model jars that contain xsd files and each one has a catalog file in "/catalog/jaxb-catalog.xml". I found that when one of my libraries call:
Class loader = Thread.currentThread().getContextClassLoader();
URL url = loader.getResource("/catalog/jaxb-catalog.xml");
It would only one xml file and ignore the second xml file as confirmed when i printed out the "url". It seems the container is "TomcatEmbeddedWebappClassLoader" However, when my application is deployed in a standalone tomcat container, the "url" would include both and the container is WebAppClassLoader.
You can read all resources with a name using
org.springframework.core.io.support.PathMatchingResourcePatternResolver
its a normal 'java' class so you can create an instance with new
to find all resources use
resolver.findResources("classpath*:catalog/jaxb-catalog.xml"
have a look at the javadoc of PathMatchingResourcePatternResolver it contains some valuable information.