I am using Spring LDAP 2.3.1 and want to customize my repository by adding my own create method. I was hoping I could use the functionality described in section 2.6 of the Spring Data Commons documentation but it did not seem to work.
Is this functionality implemented for Spring LDAP?
Not sure what you mean with own create method. Custom repository implementations are available for every Spring Data module, see reference docs.
Related
Trying to add Retry dependency in spring initializr, but only batch is showed?
Does it mean need to add spring-batch and use retry?
No. Not every possible modules that the Spring ecosystem has is on start.spring.io. We try to reduce things to what's relevant for a getting started experience.
With a project generated on start.spring.io, you already get dependency management for Spring Retry so, if you prefer to use it directly without Spring Batch or another module that uses it, you can add the jar directly. You don't need to specify a version as this is taken care for you.
I just started learning Spring Data JPA, I connected to mysql in localhost and able to save a record but I am unable to understand why it is working if I am not giving dialect property in properties file and is hibernate a default implementation of spring data instead of ibatis or Eclispe link, because in my pom.xml I just added the dependency of spring-data-jpa and never mentioned what kind of JPA implementation I want to use.
application.properties
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.
spring.datasource.url=jdbc:mysql://localhost:3306/initsoftware
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=ppppppp
spring.datasource.password=xxxxxxx
logging.level.root=DEBUG
spring.jpa.show-sql=true
Since you have an application.properties I assume you are using Spring Boot and not just Spring Data JPA.
In order to use JPA with Spring Boot you would typically add spring-boot-starter-data-jpa to your dependencies. This indeed comes with Hibernate out of the box as you can see when you inspect the dependencies.
Spring Data JPA itself doesn't come with a JPA implementation. You have to add that.
iBatis is not a JPA implementation.
If the assumption above doesn't match your scenario you can use the maven dependency plugin to inspect your (transient) dependencies. The following is a good starting point.
mvn dependency:tree -Dverbose
If you use a different build tool, it probably has a similar feature.
I am new to Spring. I am learning it from different sources. Spring Recipes, Spring In Action and Spring documentation. According to Spring 3.+, XML configuration can be ignored at all. This is good for me as a beginner.
Problem:
I am using Spring Tool Suite, is there a Spring Web project template that starts with annotations only? All the project templates I have found use XML configuration. I don't even know where to put my DispatcherServlet. I don't know where to put my controllers.
I also had the same problem when Starting out with Spring to find only annotation based templates. Then I found this from John Thompson. This project is completely annotation based and the only xml file involved is pom.xml
I recommend you to run through Spring Guides - they are up to date and use annotation based configuration.
This is guide how to make a restfull web service using spring-boot. It has description how to made project with maven, gradle or STS.
The official recommendation is to base all new projects on Spring Boot which is XML-less out of the box.
STS offers a nice integration with the Spring Initializr service: just go to "New -> Spring Starter Project", fill in a few fields like project name etc. and tick the boxes next to modules you're interested in.
Spring Boot docs contain the following phrase:
You can browse the source code of spring-boot-autoconfigure to see the
#Configuration classes that we provide (see the
META-INF/spring.factories file).
How does one browse the specified source, should that be made into a browsable link in the docs?
Appreciate any additional reading materials on how auto-configuration machinery works in Spring Boot. Thanks!
Is it possible to use a Spring container for DI from inside Eclipse plugins?
I'm wondering because I know that Eclipse causes a lot of issues with class loading, looking up things within the plugin, etc.
The plugin is intended to be distributed as a JAR.
Yes but you will need Spring DM http://www.springsource.org/osgi
The answer is yes. You can use Spring DM, but you don't have to. It is probably better with it.
I did it without Spring DM and the main concern is class loading issues (not sure if Spring DM solves them, but I guess it should). Assuming you bundle the Spring JAR in a separate plugin with dependencies, you will need to load the context with the class loader of the invoking plugin .
Example:
Plugin A - your functional plugin
Plugin B - The Spring lib plugin exporting the spring packages
Plugin A depends on B. When plugin A starts, it will load the application context, when invoking this load, you will need to do something like:
Thread.currentThread().setContextClassLoader(PluginAActivator.class.getClassLoader())
So that the loading of the classes will happen under your own class loader. Now you can use a ClassPathXmlApplicationContext to load configuration XMLs from your class path.
One small note: the default ClassPathXmlApplicationContext validates your XMLs upon loading. You may want to disable it or point your XMLs to a local schema (rather than the standard Spring schema on springframework.org), otherwise, you will connect to the internet to download the schema files upon loading and working offline will fail.
do you have a code example for your post?
This would be great, since I´m hanging around with this for a while.
Cheers!