Java's new project learning online notes-day15

3 online learning interface 3.1 requirement analysis
According to the business process below, this chapter completes the front-end learning page to request the learning service to obtain the course video address, and automatically plays the video.

3.2 build development environment
3.2.1 create database
Create XC ﹣ learning database, which will record students' course selection information and learning information.
Import: data / xc_learning.sql
3.2.2 create learning service project

Refer to the course management service engineering structure to create learning service engineering:

pom.xml 
[mw_shl_code=applescript,true] <dependencies>     <!‐‐ Import Eureka Service dependency ‐‐>     <dependency>      <groupId>org.springframework.cloud</groupId>           <artifactId>spring‐cloud‐starter‐netflix‐eureka‐client</artifactId>          </dependency>     <dependency>         <groupId>com.squareup.okhttp3</groupId>         <artifactId>okhttp</artifactId>
    </dependency>
[/mw_shl_code]
[mw_shl_code=applescript,true]<dependency>             <groupId>org.springframework.cloud</groupId>             <artifactId>spring‐cloud‐starter‐openfeign</artifactId>         </dependency>     <dependency>         <groupId>com.netflix.feign</groupId>         <artifactId>feign‐okhttp</artifactId>         <version>8.18.0</version>     </dependency>     <dependency>         <groupId>com.xuecheng</groupId>         <artifactId>xc‐service‐api</artifactId>         <version>1.0‐SNAPSHOT</version>     </dependency>     <dependency>         <groupId>com.xuecheng</groupId>         <artifactId>xc‐framework‐model</artifactId>         <version>1.0‐SNAPSHOT</version>     </dependency>     <dependency>         <groupId>com.xuecheng</groupId>         <artifactId>xc‐framework‐utils</artifactId>         <version>1.0‐SNAPSHOT</version>     </dependency>     <dependency>         <groupId>com.xuecheng</groupId>         <artifactId>xc‐framework‐common</artifactId>         <version>1.0‐SNAPSHOT</version>     </dependency>     <dependency>         <groupId>org.springframework.boot</groupId>         <artifactId>spring‐boot‐starter‐web</artifactId>     </dependency>     <dependency>         <groupId>mysql</groupId>         <artifactId>mysql‐connector‐java</artifactId>     </dependency>     <dependency>         <groupId>com.alibaba</groupId>         <artifactId>druid‐spring‐boot‐starter</artifactId>         <version>1.1.10</version>     </dependency>     <dependency>         <groupId>com.alibaba</groupId>         <artifactId>druid</artifactId>     </dependency>     <dependency>         <groupId>org.mybatis.spring.boot</groupId>         <artifactId>mybatis‐spring‐boot‐starter</artifactId>     </dependency>     <dependency>         <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper‐spring‐boot‐starter</artifactId>
</dependency>       <dependency>         <groupId>org.springframework</groupId>         <artifactId>spring‐orm</artifactId>         <version>${springframework.version}</version>  
   </dependency>    
<dependency>    
     <groupId>org.springframework.boot</groupId>       
  <artifactId>spring‐boot‐starter‐data‐jpa</artifactId>  
   </dependency>   
  <dependency>    
     <groupId>com.alibaba</groupId>      
   <artifactId>fastjson</artifactId>  
   </dependency> 
    <dependency>    
     <groupId>commons‐io</groupId>     
    <artifactId>commons‐io</artifactId>
     </dependency>  
   <dependency>     
    <groupId>org.apache.commons</groupId>     
    <artifactId>commons‐lang3</artifactId>  
   </dependency>   
  <dependency>    
     <groupId>org.springframework.boot</groupId>   
      <artifactId>spring‐boot‐starter‐test</artifactId>   
  </dependency> 
    <dependency>     
    <groupId>org.springframework.boot</groupId>     
    <artifactId>spring‐boot‐starter‐amqp</artifactId>  
   </dependency> </dependencies>
[/mw_shl_code]
[mw_shl_code=applescript,true]server:   port: ${PORT:40600} spring:   application:  
   name: xc‐service‐learning   datasource:  
   druid:       url: ${MYSQL_URL:jdbc:mysql://localhost:3306/xc_learning?characterEncoding=utf‐8}   
    username: root     
  password: mysql      
driverClassName: com.mysql.jdbc.Driver  
     initialSize: 5  #Number of initially established connections  
     minIdle: 5  #Minimum number of connections      
maxActive: 20 #Maximum number of connections   
    maxWait: 10000  #Get the maximum waiting time of the connection, MS  
     testOnBorrow: true #Check whether the connection is valid when applying for connection   
    testOnReturn: false #Check whether the connection is valid when returning the connection  
     timeBetweenEvictionRunsMillis: 60000 #Time (in milliseconds) for configuration interval to detect whether the connection is valid
minEvictableIdleTimeMillis: 300000  #Minimum lifetime of connection in connection pool (MS) Eureka: client:  
   registerWithEureka: true #Service registration switch     fetchRegistry: true #Service discovery switch 
    serviceUrl: #Address where Eureka client interacts with Eureka server, separated by commas   
    defaultZone: ${EUREKA_SERVER:http://localhost:50101/eureka/}   instance:  
   prefer‐ip‐address:  true  #Register your ip address with Eureka service    
ip‐address: ${IP_ADDRESS:127.0.0.1}  
   instance‐id: ${spring.application.name}:${server.port} #Specify instance id ribbon:  

MaxAutoRetries: 2 ා the maximum number of retries. When the service can be found in Eureka, but the service cannot be connected, it will try again. If the service cannot be found in Eureka, go to the circuit breaker directly.
MaxAutoRetriesNextServer: 3 ා number of retries to switch instances
OkToRetryOnAllOperations: false ා retry all operation requests. If it's get, it's OK. If it's post, put and other operations don't implement idempotence, it's very dangerous. So set it to false connecttimeout: 5000 ා request connection timeout.
ReadTimeout: 6000 ා timeout for request processing
[/mw_shl_code]
Startup class:

[mw_shl_code=applescript,true]@EnableDiscoveryClient @EnableFeignClients @SpringBootApplication @EntityScan("com.xuecheng.framework.domain.learning")//Scan entity class @ ComponentScan(basePackages={"com.xuecheng.api"}) / / scan interface @ ComponentScan(basePackages={"com.xuecheng.learning"}) / / scan interface @ ComponentScan(basePackages={"com.xuecheng.framework"}) / / scan all classes under common public class LearningApplication{  
     public static void main(String[] args) throws Exception {     
    SpringApplication.run(LearningApplication.class, args);  
   }     
  @Bean     
@LoadBalanced   
  public RestTemplate restTemplate() {   
      return new RestTemplate(new OkHttp3ClientHttpRequestFactory());   
  }   }[/mw_shl_code]

Tags: Java Spring MySQL snapshot Druid

Posted on Fri, 01 Nov 2019 11:34:43 -0700 by webpoet