Configuration problem: You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema with Spring Security 3.1. Please update your schema declarations to the 3.1 schema.
Offending resource: class path resource [authentication-context.xml]
In my Eclipse workspace are a set of Mavenised Spring projects on Spring verion 3.0.6..
It's a fairly large, complicated application, about a year old, with a parent pom and 6/7 sub-poms for different components. I'll title it Project A for now.
Project A has two webapps within it, a public based website and a backoffice administration area.
Recently a seperate application was built for Project A to interact with via REST calls.
However this new application, Project B runs on Spring 3.1.1. This is in the same Eclipse workspace.
Project A's customer website and Project B ran fine on the same tomcat, there were no confused dependencies.
But now that development has started on Project A's backoffice interacting with Project B, there is a conflict, in the Spring security versions when Tomcat is launched.
Current solutions we've attempted have failed, but we haven't tried updating the
Spring version in Project A (fairly sure things will break and not sure it's worth the time retesting) and
downgrading Spring in Project B seems like a horrible precedent to set.
Anyone have any experience with this?
Any help is appreciated :-)
Related
I'm using IntelliJ with the IvyIdea plugin. I added spring as dependency, rev 4.3.16 (the one my team uses).
After successfully building the project (which is a rest api), I tried to deploy it as an exploded war using tomcat 8.5.12 (again, the one my team is using).
When the deployment is running I get this exception:
NoSuchMethodException: org.springframework.web.accept.ContentNegotiationManager.getStrategy(Ljava/lang/Class;)
Reading the official documentation, I can see that the getStrategy method was introduced on Spring 4.3 so not sure what I'm doing wrong. I've tried cleaning the Ivy cache but it didn't help.
Any help would be appreciated.
I'm working on a complex project and I've decided to separate it in several small projects.
There are 2 small projects that all projects are using:
Utils: A project with common functions and HTTP calls;
Models: A project with all my entity objects.
So, utils project is made of #Service and models project is made of #Entity, just to give a quick explanation.
When I have all projects downloaded and working on my local computer when I start an application that uses models and utils projects it works perfectly fine.
When I delete models and utils from my local computer and start using it from my maven repository, the "not a managed type" error happens and I can't start my application. The same happens on a server.
On my spring boot project main class, I've tried several things, like:
#EntityScan( basePackages - ... specified all packages.
#ComponentScan(basePackages = ... specified all packages.
But nothing seems to work. I ran out of options and I'm wondering if my project is fundamentally wrong and I should rebuild my project structure into something different.
Basically:
I have 3 projects, A, B, and C;
C project has a dependency on project A and B. B project has a dependency on project A.
When I start project C, it does not load projects A and B into context and fails to start the application, trowing the "not a managed type: com.company.project-b.Class" error.
Can you help me?
I spent so much time trying to discover the real problem and it was very simple. I had imported only the mandatory libs to compile my entity project, but I also needed to import some spring boot dependencies in order to make it work.
Basically, I just copied the pom.xml from my application project to the entity project and it worked.
today I downloaded the last STS version (3.8.4.RELEASE) and I have some doubts because it seems to me that something is changed.
I have to create a simple batch application (running in the console).
It seems to me that to create this kind of project in this new realease I have to do:
File --> Spring Legacy Project --> Simple Spring Maven
It seems to me that there is no other way to create a simple console project. Why this kind of project are putted under the Spring Legacy Project? Can I do the same thing in a more modern way?
Another doubt is related to the Spring Version into the pom.xml file:
<spring-framework.version>3.2.3.RELEASE</spring-framework.version>
Why the default version is the 3.2.3.RELEASE? Can I replace it with the more m odern Spring 4^
As its name says "Spring Legacy Project" is a legacy functionality. It create old Spring projects.
Spring now is promoting Spring Boot applications, these applications have everything you need configured by default. You only need to add the dependencies that you need.
Now you need to use:
File -- > New -- Spring Starter Project
On the first view you configure the project. Where is located, maven or gradle, etc.
On the second view you choose the libraries that you will use in your porject. You choose if it is a web project, or if you need jdbc or jpa, or batch processing.
In your case, if you don't need a web application, you just don't added to the project.
You can see more about Spring boot here
https://projects.spring.io/spring-boot/
I'm using Eclipse (Neon.1) and Java 8. I know my way around Java and in the past I created Java projects by File > New > Java Project (for a POJO project). Or File > New > Dynamic Web Project (for a WAR web app project).
But today I want a project that uses Maven, Spring MVC, Spring ORM, JPA/Hibernate, and probably a couple of other things.
I'm confused about how to build this project in Eclipse.
Do I do File > New > Java Project ... and tweak it and add stuff to it?
Or do I File > New > Maven Project ... and tweak it and add stuff to it?
I've also heard that Spring Boot is a good way to get started with this kind of thing.
Any pointers or suggestions would be greatly appreciated!
I suggest you use spring boot. It's very easy to develop Spring Based applications with Java. It avoids writing lots of boilerplate code, Annotations and XML Configuration.
here's the link on how to use spring boot with maven.
https://spring.io/guides/gs/spring-boot/
The easiest way is probably using the Spring Initializr; That web interface is also provided in IDEs (cannot speak to how it's implemented in Eclipse though).
What you'll get is pom.xml file that you then can use to create a new maven project by pom file. It will load all the dependencies you choose and makes configuration simple.
I usually create a Maven Project and add any Stuff like Spring MVC, Hibernate to it. And Spring boot is highly recommended, no need to look at xml files anymore. Here is a archetype that may useful:
https://github.com/superalsrk/cn.stackbox.archetypes
Let me explan one by one.
java - programming language
Maven - Build tool and dependencies manager like npm or bower
Spring - A java framework witten top of java also contains java codes
Hibernate/JPA - is another framework in java helps to handle data access and store data in database
In eclipse You need to create a maven project which will creates the project structure. it will create a pom.xml file and then you need to add spring and jpa related dependencies.
Then maven will manage those dependencies and now you can write your programming logic to manage your data and UI.
You can refer sample project in git
You can install the m2e plugins (usually come along with eclipse already). And configure it according to your local maven installation.
And then create a web application skeleton based on the maven project templates/archetypes provided by the m2e plugin like the normal new project process.
And then you can edit the pom.xml file (Project Object Model, which is the maven project file) to include the packages you need, such as Spring, etc.
I don't have my dev machine at hand. So the above descriptions may be vague without proper screenshots. So please follow the below 2 quick guides. Hope they help.
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
https://web.liferay.com/community/wiki/-/wiki/Main/m2e-liferay+Quick+Start+Tutorial
And these:
Using Maven within the Eclipse IDE - Tutorial
Maven + Spring hello world example
Some examples related for requested technology stack:
Jersey + Spring example: https://www.mkyong.com/webservices/jax-rs/jersey-spring-integration-example/
Jersey + Hibernate + Spring example: http://www.benchresources.net/jersey-2-x-web-service-integrating-with-spring-and-hibernate-orm-framework-using-annotation/
As chaixxiv mentioned previously https://stackoverflow.com/a/40966438/5962766, to avoid boilerplate code you can use Spring Boot. More samples:
https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/
I'm looking for an example Spring MVC 2.5 web app that I can easily:
Setup as a project in Eclipse
Deploy to a local app server (using Ant/Maven)
There are a couple of example applications included with the Spring distribution ('petclinic' and 'jpetstore'), but they don't provide any Eclipse project files (or a way to generate them). They also seem a bit complicated for my needs, e.g. require a local database to be setup.
The easiest way to get up and running with a Spring MVC project is to use SpringSource Tool Suite, which is another free IDE based on Eclipse.
The integration between the IDE and Spring/Maven is tight, and it comes with an application server already setup for you to deploy your web app.
Follow these steps to get a working Spring MVC web app.
To setup a new project in STS: Click File -> New -> Spring Template Project -> Spring MVC Project
To pull in dependencies and compile your project: Right click your new project -> Run As -> Maven install
To run your project inside an application server: Right click your new project -> Run As -> Run on Server -> SpringSource tc Server
If it works, you'll see a web page saying "Congratulations! You're running Spring!"
While not specifically an app you can download, Developing a Spring Framework MVC application step-by-step covers creating a spring application in Eclipse with an ant build script, complete with unit tests.
This meets the following requirements:
Spring MVC 2.5
Project in Eclipse
Deploy to a local app server using Ant
Uses HSQL (no need to install a local DB)
There's a Maven archetype (template project structure) for Spring MVC here:
http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
That's a good starting place for this kind of investigation. To create an archetype using Maven, first install Maven:
http://maven.apache.org/plugins/maven-install-plugin/
and then create a project using the archetype:
http://maven.apache.org/guides/introduction/introduction-to-archetypes.html
You can also use the m2eclipse plugin for Eclipse to simplify this and it takes you through the stages of the project using a wizard. Just right click -> New Project -> Other, Maven and select the archetype. Hope that helps.
Just spotted http://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/ which could be interessting for you.
To generate Eclipse project files:
Use mvn eclipse:eclipse before importing the project into your workspace. This will create all required configuration files and hook your project up with all the required dependencies.
The mvc-basic and mvc-ajax sample projects in spring-samples (SVN URL: https://src.springframework.org/svn/spring-samples) are simple projects that do not need any local database support.
Use AppFuse
I got it working just as Drew described, but there is a trap for new users (meaning fresh install, no familiarity with Maven or m2eclipse). You'll get this error:
[ERROR] Error executing Maven.
[ERROR] The specified user settings file does not exist: /home/user/.m2/settings.xml
And the work around is to just make an almost empty settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
</settings>
(I later found this bug report.)
After that, I was in business. I was even able to export as a WAR file and deploy onto my installation of WebSphere Community Edition. Thank you, Drew!
A little less earlier, I wrote:
Hmph. Never mind. I gave up, shut down my machine, and when I came back, everything worked (except for a minor Maven issue I'm working on). Chalk it up to a bug.
Earlier, I wrote:
I was very excited to hear about STS, so I downloaded and installed it. It went perfectly. This is a new machine, so I have the latest of everything - java 1.6, eclipse 3.5.1, etc.
On step 2 of the above instructions, I get this error:
"The specified JRE installation does not exist"
I've set paths everywhere I can find, so I'm not sure which JRE it's complaining about. Help?
You could also use Spring Roo to do this. http://www.springsource.org/roo
You can use below link to download hello world spring mvc project
Spring MVC hello world example