Skip to content

Instantly share code, notes, and snippets.

@JavaNoobPig
JavaNoobPig / IntroductionSpring28_3.java
Created March 11, 2019 11:53
IntroductionSpring28_3
package com.pig.springboot.basic.springbootin10steps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootIn10StepsApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootIn10StepsApplication.class, args);
@JavaNoobPig
JavaNoobPig / IntroductionSpring28_4.java
Created March 13, 2019 00:42
IntroductionSpring28_4
package com.pig.springboot.basic.springbootin10steps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@SpringBootApplication
public class SpringbootIn10StepsApplication {
public static void main(String[] args) {
@JavaNoobPig
JavaNoobPig / IntroductionSpring30_1.java
Created March 14, 2019 07:20
IntroductionSpring30_1
package compig.springboot.basic.springbootin10steps;
import java.util.Arrays;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class BookController {
@JavaNoobPig
JavaNoobPig / IntroductionSpring31_1.java
Created March 14, 2019 09:05
IntroductionSpring31_1
package com.pig.spring.springaop.springaop.data;
import org.springframework.stereotype.Repository;
@Repository
public class Dao1 {
//提供資料源
public String retriveSomething() {
return "Dao1";
}
@JavaNoobPig
JavaNoobPig / IntroductionSpring31_2.java
Created March 14, 2019 09:06
IntroductionSpring31_2
package com.pig.spring.springaop.springaop.data;
import org.springframework.stereotype.Repository;
@Repository
public class Dao2 {
//提供第二個資料源
public String retriveSomething() {
return "Dao2";
}
@JavaNoobPig
JavaNoobPig / IntroductionSpring31_3.java
Last active March 14, 2019 09:17
IntroductionSpring31_3
package com.pig.spring.springaop.springaop.business;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pig.spring.springaop.springaop.data.Dao1;
@Service
public class Business1 {
//建立企業服務,並調用第一個資料源
@Autowired
@JavaNoobPig
JavaNoobPig / IntroductionSpring31_4.java
Last active March 14, 2019 09:17
IntroductionSpring31_4
package com.pig.spring.springaop.springaop.business;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pig.spring.springaop.springaop.data.Dao2;
@Service
public class Business2 {
//建立第二個企業服務,並調用第二個資料源
@Autowired
@JavaNoobPig
JavaNoobPig / IntroductionSpring31_5.java
Created March 14, 2019 09:22
IntroductionSpring31_5
package com.pig.spring.springaop.springaop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.pig.spring.springaop.springaop.business.Business1;
import com.pig.spring.springaop.springaop.business.Business2;
@JavaNoobPig
JavaNoobPig / IntroductionSpring31_6.java
Last active March 14, 2019 10:39
IntroductionSpring31_6
package com.pig.spring.springaop.springaop.aspect;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
//AOP
//Configuration
@JavaNoobPig
JavaNoobPig / IntroductionSpring31_7.java
Created March 14, 2019 10:43
IntroductionSpring31_7
package com.pig.spring.springaop.springaop.aspect;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
@Aspect
@Configuration