GroupId.artifactId.XXX
Create a class under package Main, as a program entry
Target is to store the compiled file
5. Add Code
Add a main function to the main class
1 PackageCn.zll.testproject.controller;//This is going to be the name of your package.2 Importorg.springframework.boot.SpringApplication;3 Importorg.springframework.boot.autoconfigure.SpringBootApplication;4 //add note springbootapplication, which is a composite
Reference: Sorry, all can not find, at that time did not record, finally after knowing feel should record, so behind all have in Asfood parent project of Doc folder under Record, Hope forgive me.1. Springconfig Server1.1. Pom.xmltruetruetrue1.2 Startup class@EnableConfigServer @springbootapplication Public class tomatoapplication { publicstaticvoid main (string[] args) { Springapplication.run (tomatoapplication. class , args);} }1.3 Con
: com.gary.operation.jobdemo.demo1.MyJobFactory mybatis: mapper-locations: classpath:mapper/*.xml type-aliases-package: com.hq.dispach.entity 4. After these basic configurations are complete, the project is structured as followsHere the static directory is the front-end code that holds html,javascript and so on5. The Spring boot Web does not need to be deployed under Tomcat, because it comes with Tomcat, only the main method of executing the Master program application. But we need to do
There are two ways to add Servlets, Filter, Listener in Springboot.1. Code registration with Servletregistrationbean, Filterregistrationbean, and Servletlistenerregistrationbean to gain control1) Servlet @Bean public Servletregistrationbean Servletregistrationbean () { Returnnew Servletregistrationbean (new Myservlet (), "/xs/*"); }2. After using the @servletcomponentscan annotation on the springbootapplication, the Servlet, Filte
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 settings to is loaded from a particular profiles you'll need to active it (no profiles are curren
First, use JSON
1. Using the controller in Springboot if you return an object, the data returned to the front end defaults to JSON
@RequestMapping ("Getperson") Public person
Getperson () {Person of person
= new person ();
Person.setid (0);
Person.setname ("kmagic zaozhuang zhi Xing Bus");
return person;
}
2, front end display results
{"id": 0, "name": "Kmagic Zaozhuang zhi xing Bus"}
Second, the Spring boot default is the built-in Jackson, we want to change it to Fastjson:
1, th
org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement//If a transaction annotation is added to the service implementation class in MyBatis, you need to add the annotation here
@MapperScan ("Cloud.kafka.mapper") The package location of namespace pointing to values in Mapper.xml is scanned. Public
class Kafkalogapplication {public
static void Main (string[] args) { C10/>springa
Spring Cloud Zookeeper provides Apache Zookeeper integrations for Spring Boot apps through autoconfiguration and binding t o the spring environment and other spring programming model idioms. With a few-annotations you can quickly enable and configure the common patterns inside your application and build L Arge distributed Systems with Zookeeper. The patterns provided include Service Discovery and distributed Configuration.
First to install the zookeeper, I installed here is: zookeeper-3.4.6
This
today, using springboot to connect to Linux mysql, the period has been an error, here is a simple record of the process. Tools: idea-2017,linux-7.x,mysql-5.6.40.First, let's talk about the effects of these annotations:(1)Spring Boot @SpringBootApplication,@ Enableautoconfiguration,@ComponentScan annotations, I often foolishly confused on the startup class,(2)@EnableAutoConfiguration This note is springboot Automatically configured according to the
Spring Cloud server-side registration and client invocationIn the previous article, we have set up the Spring cloud service Registry Eureka, a chapter that explains how to register a service with Eureka and how the client invokes the service.First, registration servicesFirst, the Eureka Client is introduced into the project, and the following configuration is added to the pom.xml:Then configure the address of the Eureka Registry in our Application.properties as follows:eureka.client.service-url.
Recent research on the Dubbo frameworkBelieve to see this blog, the foundation of Dubbo should haveZookeeper set up a little detour, the configuration of all kinds of trouble, Mom's good annoying.Just wanted to use Docker, but there was a simple concept for Docker.Spent the night studying Docker and found it really useful.Build a zookeeper and play it.Here is a record of some of the pits encountered!1, Springboot Introduction of Dubbo configuration fileSearch the internet for a bit, probably two
要配置Java POJO类包路径以及DAO层接口路径,以自动扫描相关注解,这里同样需要配置这两项,不同的是Spring采取的是xml配置方式,这里用Java代码+注解方式配置。新建一个JpaConfiguration.java类,其代码如下:/**Created by Song on 2017/2/15.JPA 配置类*/@Order(Ordered.HIGHEST_PRECEDENCE)br/>*/@Order(Ordered.HIGHEST_PRECEDENCE)@EnableTransactionManagement(proxyTargetClass = true)@EnableJpaRepositories(basePackages = "com.song.repository")@EntityScan(basePackages = "com.song.entity")public class JpaConfiguration {@Beanbr/>@Beanreturn new PersistenceExceptionTranslatio
;Importorg.springframework.boot.autoconfigure.SpringBootApplication;/*** Specifies the package to be swept, will automatically scan the specified package under the all labeled @component class, and registered as a bean, * of course, including @component sub-annotations @service, @Repository, @Controller. * @author85060 **/@SpringBootApplication (scanbasepackages={"Com.example.*"}) @MapperScan ("Com.example.dao") Public classspringbootdemoapplication {
First, the new general Maven projectPom.xmlSecond, write the code@SpringBootApplication@RestControllerpublic class Application{ @RequestMapping("/hello") public String hello(){ return "hello world"; } @RequestMapping("/geeting") public String geeting(){ return "Index page"; } @RequestMapping("/geeting/{user}") public String get(@PathVariable("user") String name ){ if(name.equals("zhangsan")){ return name+" Hello"; } return "hello"; } public st
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.