Need to create a webapp in java using spring boot which has UI and also it functions as a webservice. (web-app + webservice using spring boot). How to do the configurations ?
I think that this question is a bit wide. You should start by reading some tutorial like :
http://projects.spring.io/spring-boot/
I don't really know a good option to do UI with spring boot, but maybe look at :
https://spring.io/guides/gs/crud-with-vaadin/
You will need to learn and read a bit but I hope it helped you :)
EmCode
Select the SpringBoot example that is most close to your problem space and extend. You can find the samples Here.
Alternatively you can use the Spring Initializr
This is an example of Web app from the original spring page:
https://spring.io/guides/gs/spring-boot/
And this for webservices
https://spring.io/guides/gs/actuator-service/
You only need to start from the first example and add configuration in the 2nd
Related
Can anyone please help me on how to integrate Olingo (Odata) in a Springboot Java Appln.
I'm pretty new to Spring boot and have implemented one project and wanted it to convert to Oling (Odata).
I have gone through various resources but with a bunch of different approaches not sure how to do it the correct way.
Please let me know if some has worked on it and can guide me.
link to the project on which I applied spring-boot.
If you are trying to integrate OlingoJPA there are a couple of things you will have to do
Implement JPAServiceFactory and initializeODataJPAContext, basically this is about defining the persistence unit and entity manager
Then you can create a Spring Boot Configuration to mount your OData endpoint and initialize the EntityManagerFactory
Then you can point to your database here
An finally you can define the JPA entities you want your service to expose
The full Spring Boot + JPA project sample is located Github. Feel free to go though it, raise an issue or submit a Pull request for impalements
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 wanted to create a spring security config for rest controller with OAuth2 but the current project already have a spring security config for regular controller.
Question is: (1) do I make a separate spring sec config with oauth for rest controller? or
(2) just include it to the exiting setup?
Any suggestion will be appreciated and any links for a tutorial will be a great help. Thanks!
After googling alot, Finally, my config is now working. found out that the config can be in one class or may separate it. Thanks to the config below.
https://github.com/spring-projects/spring-security-oauth/blob/master/samples/oauth2/sparklr/src/main/java/org/springframework/security/oauth/examples/sparklr/config/OAuth2ServerConfig.java
the project is also working.
I am new to Spring portlet i am unable to run a sample spring portlet project.. I am trying to run the project from eclipse as run on server on jboss server. My questions are 1. How can we run a portlet project. Do i need some kind of portlet container(I have no idea of this container i just know few names like liferay etc)?? I cant find a full documented example any where.. In Spring mvc based on the request mapping i can call that purticular Controller class but in Spring mvc portlet how can we call this controllers( or Portlets). Is it possible to call a portlet directly by an url?? The sample project is deployed without any error but i cant find a way by which i can call or trigger a portlet. Any help would be much appriciated.
thx
nkovi
Yes, you will need to deploy to a portlet container like Liferay etc, or uPortal. Once you have the portlet container up and running, things should hopefully become more obvious.
Regarding your other questions, I strongly suggest you read some documentation - the Spring portlet docs are not too bad although they are a little behind on annotations.
I mean to say like for html/css/jquery etc. we have w3schools like that is there any web site or e-material for starting up with spring and spring security.
I recommend the spring security documentation getting start steps.
http://static.springsource.org/spring-security/site/start-here.html
I would suggest going through this tutorial to see a concrete implementation:
http://krams915.blogspot.com/2010/12/spring-security-mvc-integration.html (Part 1)
http://krams915.blogspot.com/2010/12/spring-security-mvc-integration_18.html (Part 2)
It provides a description and example of every file you'll have to set up, and a download of the tutorial project at the end of each tutorial.