Read about why spring boot is used for microservices, The latest news, videos, and discussion topics about why spring boot is used for microservices from alibabacloud.com
Today, while watching Spring's demo, I saw how the unit test was written
As follows:
@RunWIth (Springjunit4classrunner.class)
@ContextConfiguration (locations = {"Classpath:applicationContext.xml"}
public class MyTest
{
@Test
public void hehe ()
{
//.......
}
}
This is written to allow the test to execute in the spring container environment.
What is Spring's co
problem
When you select a data source for a project framework that is automatically generated by springboot, such as by selecting MySQL, the startup will report an exception after the project is built:
Description:
cannot determine embedded database driver class for database type NONE
Action:
If your want an EMB edded database Please put a supported one on the classpath. If you are have database setting
SPRING4 provides support for WebSocket, but online demos are used in the context of spring MVC.
In fact, Spring-websocket is not dependent on SPRINGMVC.
The key is to map the WebSocket address to the URL for triggering the front end.
Also, the first time WebSocket
Locate the project's application configuration file, add Spring.session.store-type=none, restart the problem resolutionNote: Because the project does not use the Redis management session, you can set it up, if you want to use the Redis management session, you can modify it to Spring.session.store-type=redisSpring Boot Project Launch report (No session repository could be auto-configured, check your configuration (session store type
The core Hystrix,hystrix is very good protection for interface calls, it can effectively provide the usability of the application in the multi-service dependent distributed system, and the failure application can be fused and resumed, so that the application is stable in the complex environment.http://tech.lede.com/2017/06/15/rd/server/hystrix/Hystrix can also be used
Background: The Spring Boot integrated Servlet is released as a ready-to-run war package for later packaging as a Docker image.
Original Address Https://github.com/weibaohui/springboot-servlet-jsp-war-demo
#1, Build.gradle configuration note, added the war plug-in, the dependency of Jstl, Tomcat-embed-jasper, so as to run the JSP page.buildscript { ex
Today, I encountered a strange thing. I configured transactions in the Spring configuration file and performed transactions on all methods at the Service layer. However, when I tested one of the methods, it is found that it is not a transaction, and the first operation in it is completed, but the second operation fails
In Spring, @ RequestParam is used to accept url parameters of the Date type, @ requestparamdate
First introduce the joda-time package. Maven dependency:
In the Controller code:
public String testMethod(@RequestParam @DateTimeFormat(pattern="yyyy-MM-dd") Date testdate){ System.out.println(testDate);}
Use pattern to specify the date format.
Test url:
?
In Spring MVC, Swagger2 is used to build a dynamic RESTful API.
When multiple terminals (WEB/mobile terminals) require public service logic, a RESTful service is generally built for multiple terminals.
To reduce frequent communication costs with the corresponding terminal development team, we will create a RESTful API
Spring's jdbctemplate operations
1.Spring Frame One-stop framework for Java EE Three layer, each layer has a resolution technology on the DAO layer, using JdbcTemplate
2.Spring support for different persistence technologies Spring provides templates and callbacks for simple operations for a variety of supported persistence technologies. ORM Persistence Technology
The static directory of the spring boot program defaults to the Resources/static directory, which, when packaged as a jar, packs the static directory in such a way that there are some problems:
Too many static files, resulting in too large jar package size
Temporary modification Inconvenient
Looking at the official documentation, you can see that the static can be external.Method 1 Modify
The Spring boot project defaults to using an inline tomcat package as a jar, and we can make some changes to package it as a war package:modifying Maven's Pom.xml Packaging >Warpackaging>The inline tomcat dependency is then modified to:Dependency> groupId>Org.springframework.bootgroupId> Artifactid>Sprin
I wrote a spring program with Javase, and for the whole afternoon, there was a problem with JDBC configuration and access.
1, the old version of the book many use is simplejdbctemplate, looking for a long time, found that the new version of spring does not have this class, replaced by Org.springframework.jdbc.core.JdbcTemplate. function seems to be a simplejdbct
A spring boot project, if packaged into a jar file, can be separated from the IDE and started directly through the Java-jar command, which is convenient. Maven Project
The first way:
IntelliJ idea under Start
First modify the packaging of the Pom as a jar
Open the Terminal window CD into this item 1. Perform MVN clean package
Springbootweb01-0.0.1-snapshot.jar fi
The springredistemplate is encapsulated for this scan, and the sample is used (for the latest library spring-data-redis-1.8.1.release):Setexecute = redistemplate. Execute (new rediscallbacksetpublic setsetnew HashSet new Scanoptions.scanoptionsbuilder (). Match ("test*"). Count ( ) . Build ()); While (Cursor.hasnext ()
1, when loading the configuration file definition, determine which authenticationmanager to useWhen the configuration file Security.xml is loaded, a providermanager is created first, and thenIf you configured the default Authenauthmanager (HTTP attribute authentication-manager-ref), use the default as the parent of ProvidermanagerIf no default authenauthmanager (HTTP attribute authentication-manager-ref)
Association query is used in the framework of spring + hibernate3.
Table User: address is a one-to-many relationship.Userbean has a set of addresses
Now you need to query such a user, which owns the user whose doorplate is "642" in the address,Currently, there
Tags: conf list reference nbsp LIS net any over preThe error is as follows:Template might not exist or might is accessible by any of the configured Template resolversWorkaround:1. Determine if the template is in the default Templates folder, and the path is the same as the return view name.2, New Modelandview ("/log/lo
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.