Discover spring boot mongodb example, include the articles, news, trends, analysis and practical advice about spring boot mongodb example on alibabacloud.com
Spring Cloud FeignSpring Cloud Feign is a set of declarative service invocation clients based on the Netflix feign implementation. It makes writing Web service clients easier. We only need to configure it by creating an interface and using annotations to complete the binding to the Web service interface. It features pluggable annotation support, including feign annotations, Jax-rs annotations. It also supports pluggable encoders and decoders.
default all parameters of the method are combined (e.g.: @Cacheable (value= "user", key= "#username"))Value: The name of the cache, as defined in the spring configuration file, must specify at least one (for example: @Cacheable (value= "user") or @cacheable (value={"user1", "User2"})Condition: Cached condition, can be empty, written with Spel, returns TRUE or FALSE, only true for caching (such as: @Cacheab
Quick StartThe main objective of this chapter is to build the Spring Boot Foundation project and implement a simple HTTP request processing, which gives a preliminary understanding of spring boot and experiences its simple structure and rapid development.System Requirements:
Java 7 and above
http://blog.csdn.net/qq18998401056/article/details/53467671**************************************************************************In spring boot, the appropriate cache manager (CacheManager) is configured with @enablecaching annotation automation, and Spring boot detects the cache provider according to the following
after the install, and then Java-jar Xxx.jar mode can not start )
The target depends on the dependencies configuration:
Spring-boot-starter-web: Full stack Web development module with embedded tomcat, spring MVC
Spring-boot-starter-test: Generic t
1. Maven constructs spring Boot
Create a MAVEN Web project that introduces spring-boot-starter-parent dependencies
Using Spring-boot-starter-parent to build a spring
overrides the parameters in the configuration file * If no value is specified, then the default value for name is world. */@ Value ("${Name: World}") private String name; /** * Due to the use of @restcontrolelr, it is not necessary to use @responsebody to label the returned results */@ requestmapping ("/Hello") public String SayHello () { return String. Format ("hello:%S", name);}} To write a spring boot
directory @PropertySource
This annotation can specify a specific property configuration file with a lower priority. springapplication.setdefaultproperties
For example:
Springapplication application = new Springapplication (application.class);
map1 2 3 4 5 6 1 2 3 4 5-6
apply (use) Properties
@Value ("${xxx}")
This is the simplest way to inject attribute values through @value annotations. @ConfigurationProperties
Directory:One . MongoDB Boot configuration Two . Export , import , run-time backup Three . Fsync lock , data repair Iv. . User Management , Security certification First, the startup item Mongod--helpC:\windows\system32>mongod--help1. Common Configuration Items
--dbpath
Specifies the directory for the database , which is c:\data\db\ by default under Window
--po
Static resource accessWhen we develop Web applications, we need to reference a large number of JS, CSS, pictures and other static resources.Default configurationSpring boot defaults to provide a static resource directory location to be placed under Classpath, and the directory name must conform to the following rules:
/static
/public
/resources
/meta-inf/resources
Example: We can c
Spring boot starts on the first day, see the example of @restcontroller ....The same point: both are used to indicate whether a class in spring can receive HTTP requestsDifferent points: @Controller identify a spring class that is a spri
is Spring Data JPA capable of?can greatly simplify the The JPA notation enables access to and manipulation of data in situations where there is little or no write implementation. except CRUD , it also includes some common functions such as paging, sorting, and so on. first of all, we need to be clear Spring Data is an open source framework in which spring data J
UTF-8 encoding relies on the management module, You can omit the
The POM project only supports single inheritance, but sometimes we have to inherit from other Pom, or use our own configuration. At this point, if we want to add support for Spring Boot, it can be done in other ways.
We can do dependency management by introducing spring-
@EnableAutoConfiguration annotation?
This annotation tells Spring Boot to "guess" what you'll want to configure Spring, based on the jar dependencies that's you Have added.Read more @enableautoconfiguration Spring Boot example
; - - @Target ({elementtype.type}) - @Retention (retentionpolicy.runtime) + @Documented - @Inherited + @Configuration A @EnableAutoConfiguration at @ComponentScan - Public@Interfacespringbootapplication { -Classdefault {}; - -String[] Excludename ()default {}; -}springbootapplication Source@SpringBootApplication annotations are mainly composed of @configuration, @EnableAutoConfiguration, @ComponentScan If you do not use @springbootapplication annotations, you can use @configuration, @EnableAu
PomThe first is increased, the addition of parent Pom is relatively simple, and Spring-boot-starter-parent contains a large number of well-configured dependency management, do not need to write the version number when you add these dependencies to your project.Using parent pom is simple, but there are cases where we already have a parent pom that cannot be added directly when you can do this by:
1.1.3 Ab
see, our service has been successfully started.4.5 Process AnalysisYou might wonder why we didn't configure the database information, but we didn't report the exception. We clearly created the Readrepository database interface, if there is no datasource, it should be reported abnormal. But spring boot cleverly avoids the problem.First we need to know about spring
Spring Boot creates beans using Java code and registers them to Spring.
From Spring3.0, a new method is added to configure Bean Definition, which is to configure Bean Definition through Java Code.The two configuration methods differ from Xml and Annotation:
The first two Xml and Annotation configuration methods are pre-defined, that is, after developers use the X
Setenvironment is run when the system is started.Or, for example, the following controller:@Controllerpublicclass PageController implements EnvironmentAware{ @Override publicvoidsetEnvironment(Environment environment) { String s = environment.getProperty("JAVA_HOME"); System.out.println(s); }}We can also read the properties in the Application property configuration file via @configurationproperties. @Configuration @Conditiona
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.