I am trying to use Enunciate to generate static documentation for my REST API that is written in Java using Spring MVC 3.2. The Enunciate website claims that it has Spring support by using a specific plugin here :
http://enunciate.codehaus.org/module_spring_app.html
When looking at the configuration options, it looks like I am supposed to import a spring applicationContext.xml. I use the annotation-based configuration for this project, so I don't have an applicationContext.xml. Is there a way to make this work in my case?
Thanks in advance for any help.
Enunciate currently supports Spring Web annotations.
Related
Can I use springboot annotations like #Bean, #Component, #Autowired etc in plain java project with just using gradle dependencies?
To use spring frameworks annotations the project should be either spring boot or a project with all the required spring dependencies to support the above mentioned annotations.
No. Spring uses those annotations for the inversion of control. Without this framework they are useless in plain java.
I have a set of RestControllers in a spring reactive web project and I want to prefix all of the controllers with "api" or "test-api" in different environments.
I have tried to use server.servlet.context-path=/api and it's not working with spring reactive web (webflux) running on Netty server
The following property was added in spring boot 2.3 to achieve this with webflux
spring.webflux.base-path
Release Notes: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#configurable-base-path-for-webflux-applications
Have you tried using a placeholders in #RequestMapping, like for example #RequestMapping("${foo.bar}") ?
Thank you
I once successfully implemented Apache Shiro in a desktop standalone application (without Spring framework or any framework for that matter).
I used INI file to get SecurityManager like so:
Factory<org.apache.shiro.mgt.SecurityManager> factory = new IniSecurityManagerFactory(
"classpath:resources/shiro.ini");
org.apache.shiro.mgt.SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
Subject currentUser = SecurityUtils.getSubject();
I read in one of stackoverflow post that it is not advisable to use shiro INI when using spring.
In my case now I use Spring Boot with Spring Data JPA with Hibernate in this application. What is the best way to configure Apache Shiro so that I can maximise the use of this security framework.
Edit
All examples i have come across, shows examples for web. I need specifically for standalone application. Examples will highly be appreciated.
Solution
After alot of learning and answers from this post, i managed to come up with this solution and created github repo. If anyone wishes to make it better, be my guest.
As I understand doesn't mutter if you are developing a web-based application or a standalone, unless for the webfilters official Apache shiro doc as you can see here this example shows how to properly configure apache shiro for both, web-based and standalone.
You can still use xml-based configurations,as is described here with spring boot and it's easy migrate configuration from INI files to XML using tags like or constructor-args as shown here spring xsd doc
In my opinion use INI file or XML-based configurations has smiilar advanteges and disadvantages, in both methods you can "hot-swap" beans configurations.
For instance if it's easy for you use Java or configurate Shiro on code you can check this github link where you can see an example Class configuration for apache Shiro spring-boot application.
Forget about the web filters and configure the others beans as on this links it should work fine.
As far as i know there is no a good or a worng way talking about use xml or class configurations with spring boot, it just depend on what your needs are.
To finish I code a simple example Spring-boot-standalone with shiro. for you to demostrate an XML-based configuration, this prints the realm bean to show that the context is up and has commented code to fulfill with your needs the rest must be compleate beans with the shiro webpage tutorial.
Greatings.
You can use a yml file to add shiro configurations along with you the application properties.
As an example, take a look at https://github.com/johntostring/spring-boot-shiro
I am looking at Spring documentation to learn Spring integration with Hibernate using annotation based spring configuration.
The documentation link is here.
Now the docs tell about how to configure Spring with Hibernate using xml files and there is no where mentioned how to use annotations for integrating Spring and Hibernate.
Please help me where can I find the explanation on Spring with Hibernate integration using annotations.
You can find the required annotations here - Annotations used for configuring DAO or Repository classes
Here is a good example for using Spring with Hibernate - Spring Hibernate Integration Using Annotations
http://examples.javacodegeeks.com/enterprise-java/hibernate/hibernate-jpa-dao-example/
I'm not sure if I should downvote you - you could easily find it on your own.
Ok, maybe it is not exactly Spring + Hibernate, but it really does not matter.
What's the best method to initiate a new Spring Project ?
Initiating Spring project is a lot of pain with various xml and db configuration.
Is there an "official" repository with complete sample project, as MVC with db access and so ?
Spring Boot may also be the solution, but some point still not clear to me :
How to add external components (such as Quartz) without creating some xml config ? (No such xml in Boot apparently)
Is a Spring Boot builded app is production-proof ?
As writen in the comments http://start.spring.io/ is the best way to start Spring boot project(STS has integration for it).
If you want to use something that is not supported by Spring Boot you can init spring beans the same way you do it in xml, just use java configuration. See this for example: http://www.tutorialspoint.com/spring/spring_java_based_configuration.htm
Also useing xml is still available. You can add #ImportResource on your Configuration class
#EnableAutoConfiguration
#Configuration
#ImportResource({"classpath*:applicationContext.xml"})