728x90

라라벨의 기능중에서 DB관련 파사드 지원해 줍니다.

SQL 삽입 과 같은 악의적 공격 원천 차단하기 위해서 파사드를 사용합니다.

이를 이용해서 실제 DB에 데이터를 넣고 테스트를 할 수 있습니다.

그중에서 tinker의 사용법을 알아보겠습니다


1. Mysql 유저 생성 및 DB 생성하기 (mysql DB서버에 접속할 로그인 정보를 만든다고 생각하세요)

hanui-MacBook-Pro:NationalPension hanchiro$ mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 15

Server version: 5.7.16 MySQL Community Server (GPL)



Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.



Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.



Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



 

 

mysql > use mysql;
mysql > create database posts;
-- posts 라는 데이터베이스를 만들었습니다.

mysql > create USER '유저' IDENTIFIED BY '비밀번호';
-- 유저로 '유저' 라는 아이디를 만들어서 '비밀번호'와 함께 생성해줍니다.

mysql > grant all privileges on posts.* to '유저';
-- posts 로 시작하는 DB에 대해서 posts라는 데이터베이스 를 찾아서 '유저'에 대해 권한을 부여합니다.

mysql > flush privileges;
-- 해당 설정값이 mysql 에 적용이 되도록 해줍니다.

mysql > quit;
-- 나옵니다.

 

mysql > use mysql;
mysql > create database posts;
mysql > create USER 'postsID' IDENTIFIED BY 'postsPASSWORD';
mysql > grant all privileges on posts.* to 'postsID';
mysql > flush privileges;
mysql > quit;

 

생성한 DB명 : posts

생성한 USER아이디 : postsID

생성한 PASSWORD : postsPASSWORD

 

를 만들어 뒀습니다.(꼭 수정해서 mysql DB 를 만들어 쓰세요 ^^)

그리고 이 DB 로그인 정보는 꼭 기억해 두세요.

 

 

2. posts 테이블 만들기

mysql  서버에 접속해서 posts DB에 접속한 다음에  "use posts"  로 posts DB로 이동합니다.

hanui-MacBook-Pro:NationalPension hanchiro$ mysql -u root -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 15

Server version: 5.7.16 MySQL Community Server (GPL)



Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.



Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.



Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use posts

 

아래와 같이 posts  데이터베이스 안에 posts라는 테이블을 만들어 줍니다.

create table posts(
	id int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
	title varchar(255) NOT NULL default '',
	contents TEXT NOT NULL,
	regDate datetime NOT NULL
)ENGINE=InnoDB DEFAULT Charset=UTF8 Collate=utf8_unicode_ci;

 

 


3. laravel 설정파일 .env 파일에 파란박스 부분에 DB 를 생성할때의 내용을 입력 해줍니다.

1. 번에서 생성한

생성한 DB명 : posts

생성한 USER아이디 : postsID

생성한 PASSWORD : postsPASSWORD

를 .env 파일에 똑같은 쌍으로 입력 해주세요

 

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=생성한 DB명
DB_USERNAME=생성한 USER아이디
DB_PASSWORD=생성한 PASSWORD

 

 

 

 


4. php artisan tinker 사용하기!! 

hanui-MacBook-Pro:NationalPension hanchiro$ php artisan tinker

Psy Shell v0.9.12 (PHP 7.1.1 — cli) by Justin Hileman

 

DB::insert

>>> DB::insert('insert into posts(title,contents,regDate)values(?,?,now())', ['hello chiro','고마워 tinker 야']);

>>> DB::insert('insert into posts(title,contents,regDate)values(?,?,now())', ['잘지내고 있나요?','잘 지내고 있나요? 전 요즈음 영어공부를 하고 있어요']);

>>> DB::insert('insert into posts(title,contents,regDate)values(?,?,now())', ['how do you today?','how do you today? those day I have been study english']);

 

>>> DB::insert('insert into posts(title,contents,stDate)values(?,?,now()), ['hello chiro','고마워 tinker 야']);

PHP Parse error: Syntax error, unexpected T_STRING, expecting ')' on line 1

>>> DB::insert('insert into posts(title,contents,stDate)values(?,?,now()), ['hello chiro','고마워 tinker 야']');

PHP Parse error: Syntax error, unexpected T_STRING, expecting ')' on line 1

>>> DB::insert('insert into posts(title,contents,stDate)values(?,?,now())', ['hello chiro','고마워 tinker 야']);

Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stDate' in 'field list' (SQL: insert into posts(title,contents,stDate)values(hello chiro,고마워 tinker 야,now()))'


>>> DB::insert('insert into posts(title,contents,regDate)values(?,?,now())', ['hello chiro','고마워 tinker 야']);

=> true

>>> DB::table('posts')->get();

=> Illuminate\Support\Collection {#2910

     all: [

       {#2900

         +"id": 1,

         +"title": "hello chiro",

         +"contents": "고마워 tinker 야",

         +"regDate": "2020-02-12 16:12:02",

       },

     ],

   }


>>> DB::insert('insert into posts(title,contents,regDate)values(?,?,now())', ['잘지내고 있나요?','잘 지내고 있나요? 전 요즈음 영어공부를 하고 있어요']);

=> true

>>> DB::insert('insert into posts(title,contents,regDate)values(?,?,now())', ['how do you today?','how do you today? those day I have been study english']);

=> true

>>> DB::table('posts')->get();

=> Illuminate\Support\Collection {#2914

     all: [

       {#2913

         +"id": 1,

         +"title": "hello chiro",

         +"contents": "고마워 tinker 야",

         +"regDate": "2020-02-12 16:12:02",

       },

       {#2896

         +"id": 2,

         +"title": "잘지내고 있나요?",

         +"contents": "잘 지내고 있나요? 전 요즈음 영어공부를 하고 있어요",

         +"regDate": "2020-02-12 16:12:39",

       },

       {#2908

         +"id": 3,

         +"title": "how do you today?",

         +"contents": "how do you today? those day I have been study english",

         +"regDate": "2020-02-12 16:14:16",

       },

     ],

   }

 

DB::select

>>> $posts = DB::select('select * from posts');

>>> $posts[0]->title;

>>> $posts[1]->title;

>>> $posts[3]->title;

>>> $posts[2]->title;

>>> $posts = DB:select('select * from posts');

PHP Parse error: Syntax error, unexpected ':' on line 1

>>> $posts = DB::select('select * from posts');

=> [

     {#2915

       +"id": 1,

       +"title": "hello chiro",

       +"contents": "고마워 tinker 야",

       +"regDate": "2020-02-12 16:12:02",

     },

     {#2907

       +"id": 2,

       +"title": "잘지내고 있나요?",

       +"contents": "잘 지내고 있나요? 전 요즈음 영어공부를 하고 있어요",

       +"regDate": "2020-02-12 16:12:39",

     },

     {#2912

       +"id": 3,

       +"title": "how do you today?",

       +"contents": "how do you today? those day I have been study english",

       +"regDate": "2020-02-12 16:14:16",

     },

   ]

>>> $posts[0]->title;

=> "hello chiro"

>>> $posts[1]->title;

=> "잘지내고 있나요?"

>>> $posts[3]->title;

PHP Notice:  Undefined offset: 3 in Psy Shell code on line 1

>>> $posts[2]->title;

=> "how do you today?"

>>> $post = DB:selectOne('select * from posts');

PHP Parse error: Syntax error, unexpected ':' on line 1

 

DB::selectOne

>>> $post = DB::selectOne('select * from posts');

>>> $post = DB::selectOne('select * from posts');



=> {#2909

     +"id": 1,

     +"title": "hello chiro",

     +"contents": "고마워 tinker 야",

     +"regDate": "2020-02-12 16:12:02",

   }

>>> $post->title;

=> "hello chiro"

>>> 

 

DB::table('posts')->first();

>>> DB::table('posts')->last();

>>> DB::table('posts')->first();
=> {#2920
     +"id": 1,
     +"title": "hello chiro",
     +"contents": "고마워 tinker 야",
     +"regDate": "2020-02-12 16:12:02",
   }

 

DB::table('posts')->last(); 는 안되네요

>>> DB::table('posts')->last();

BadMethodCallException with message 'Call to undefined method Illuminate/Database/Query/Builder::last()'

 

 

 

 

>>> DB::table('posts')->find(); 는 안되네요

>>> DB::table('posts')->find();
TypeError: Too few arguments to function Illuminate/Database/Query/Builder::find(), 0 passed in Psy Shell code on line 1 and at least 1 expected

 

DB::table('posts')->find(2);

>>> DB::table('posts')->find(2);

=> {#2918

     +"id": 2,

     +"title": "잘지내고 있나요?",

     +"contents": "잘 지내고 있나요? 전 요즈음 영어공부를 하고 있어요",

     +"regDate": "2020-02-12 16:12:39",

   }

 

>>> DB::table('posts')->find(1,2); 안되요

>>> DB::table('posts')->find(1,2);

TypeError: Argument 1 passed to Illuminate/Database/Grammar::columnize() must be of the type array, integer given, called in /Users/hanchiro/dev/workspace_php/NationalPension/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 131

 

DB::table('posts')->find([1,2]); 이건 좀 이상하네요.

>>> DB::table('posts')->find([1,2]);

=> {#2914

     +"id": 1,

     +"title": "hello chiro",

     +"contents": "고마워 tinker 야",

     +"regDate": "2020-02-12 16:12:02",

   }

>>> DB::table('posts')->find([2,3]);

=> {#2920

     +"id": 2,

     +"title": "잘지내고 있나요?",

     +"contents": "잘 지내고 있나요? 전 요즈음 영어공부를 하고 있어요",

     +"regDate": "2020-02-12 16:12:39",

   }

 

DB::table('posts')->find([2]);

>>> DB::table('posts')->find([2]);

=> {#2900

     +"id": 2,

     +"title": "잘지내고 있나요?",

     +"contents": "잘 지내고 있나요? 전 요즈음 영어공부를 하고 있어요",

     +"regDate": "2020-02-12 16:12:39",

   }

 

DB::table('posts')->find([1-2]); --> null 이 나오네요

>>> DB::table('posts')->find([1-2]);

=> null

 

 

DB::table('posts')->where('id=1); 은 안되요

>>> DB::table('posts')->where('id=1);

PHP Parse error: Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE on line 1

 

DB::table('posts')->where('id','=',1); 에서 ->get()을 해줘야 해요.

>>> DB::table('posts')->where('id','=',1);

=> Illuminate\Database\Query\Builder {#2924

     +connection: Illuminate\Database\MySqlConnection {#2904},

     +grammar: Illuminate\Database\Query\Grammars\MySqlGrammar {#2903},

     +processor: Illuminate\Database\Query\Processors\MySqlProcessor {#2902},

     +bindings: [

       "select" => [],

       "join" => [],

       "where" => [

         1,

       ],

       "having" => [],

       "order" => [],

       "union" => [],

     ],

     +aggregate: null,

     +columns: null,

     +distinct: false,

     +from: "posts",

     +joins: null,

     +wheres: [

       [

         "type" => "Basic",

         "column" => "id",

         "operator" => "=",

         "value" => 1,

         "boolean" => "and",

       ],

     ],

     +groups: null,

     +havings: null,

     +orders: null,

     +limit: null,

     +offset: null,

     +unions: null,

     +unionLimit: null,

     +unionOffset: null,

     +unionOrders: null,

     +lock: null,

     +operators: [

       "=",

       "<",

       ">",

       "<=",

       ">=",

       "<>",

       "!=",

       "<=>",

       "like",

       "like binary",

       "not like",

       "ilike",

       "&",

       "|",

       "^",

       "<<",

       ">>",

       "rlike",

       "regexp",

       "not regexp",

       "~",

       "~*",

       "!~",

       "!~*",

       "similar to",

       "not similar to",

       "not ilike",

       "~~*",

       "!~~*",

     ],

     +useWritePdo: false,

   }

 

 

DB::table('posts')->where('id','=',1)->get();

DB::table('posts')->where('id',1)->get();

DB::table('posts')->whereId('1')->get();

 

id가 1인 테이블 정보를 가져오는 똑같은 표현식입니다.

>>> DB::table('posts')->where('id','=',1)->get();

=> Illuminate\Support\Collection {#2932

     all: [

       {#2930

         +"id": 1,

         +"title": "hello chiro",

         +"contents": "고마워 tinker 야",

         +"regDate": "2020-02-12 16:12:02",

       },

     ],

   }

>>> DB::table('posts')->where('id',1)->get();

=> Illuminate\Support\Collection {#2919

     all: [

       {#2899

         +"id": 1,

         +"title": "hello chiro",

         +"contents": "고마워 tinker 야",

         +"regDate": "2020-02-12 16:12:02",

       },

     ],

   }


>>> DB::table('posts')->whereId('1')->get();

=> Illuminate\Support\Collection {#2924

     all: [

       {#2932

         +"id": 1,

         +"title": "hello chiro",

         +"contents": "고마워 tinker 야",

         +"regDate": "2020-02-12 16:12:02",

       },

     ],

   }

 

 

DB::table('posts')->where(function($query){ $query->whereId(1); })->get();

콜백 함수로 where 절에 대한 조건문을 입력할 수 있어요.

 

>>> DB::table('posts')->where(function($query){ $query->whereId(1); })->get();

=> Illuminate\Support\Collection {#2937

     all: [

       {#2936

         +"id": 1,

         +"title": "hello chiro",

         +"contents": "고마워 tinker 야",

         +"regDate": "2020-02-12 16:12:02",

       },

     ],

   }

>>> 

 

728x90

Spring Boot Starter & Parent 로 간단히 의존성 설정하기

http://dveamer.github.io/backend/SpringBootStater.html

 

 

순수 Java 프로젝트는 필요한 라이브러리를 사용하기 위해선 라이브러리 파일들을 직접 보관하고 관리해야 했습니다. 

 

Maven, Gradle과 같은 프로젝트 관리 툴을 이용하면서 라이브러리의 정보, 버전, 의존성을 문서(pom.xml, build.gradle)에 작성만 해도 라이브러리를 사용할 수 있게 되었고 덕분에 관리와 공유할 수 있게 되었습니다.

하지만 여전히 라이브러리간의 의존성 관리와 버전 충돌은 우리들이 직접 해결하고 매번 작성해야 합니다.

 

Python은 PIP라는 패키지 매니저를 통해 패키지를 설치하면 해당 패키지와 의존성을 갖는 패키지 조합을 사전에 정의되어있는 버전에 맞게 자동으로 설치해줍니다.

PHP 7 에서는 composer를 통해서 이런 작업들을 할 수 있게 도와주고 있습니다.

nodejs 에서는 npm 에서 이런 작업들을 도와주고 있습니다.

 

그리고 Spring boot 에서도 이런 라이브러리 간의 의존성관리 및 버전 충돌에 대한 이슈를 굉장히 쉽고 빠르고 정확하게 의존성 설정을 할 수 있도록 도와주는 라이브러리가 있습니다.

 

그것이 바로 spring-boot-stater와 spring-boot-stater-parent입니다.

Spring 진영에서는 이러한 문제를 해결해주는 spring-boot-starter와 spring-boot-stater-parent를 제공했습니다. 

Spring Boot를 사용하면서 자주 사용하게 되는 라이브러리간의 의존성, 버전 조합을 각각 테스트한 뒤 공개했다고 보시면 됩니다. 

Spring 진영의 신뢰성 높은 검증을 거친 이 의존성 조합은 비록 세상 모든 라이브러리의 조합을 커버하지는 못하지만 자주 사용되는 라이브러리들에 대해서만큼은 스트레스를 받지 않고 설정할 수 있게 해줍니다.


Spring Boot Starter

프로젝트에 설정해야 할 다수의 의존성들을 사전에 미리 정의해서 의존성 조합 제공

Spring Boot에서는 spring-boot-starter라는 사전에 미리 정의한 편리한 의존성 조합을 제공합니다.

프로젝트에 설정해야하는 다수의 의존성들을 starter가 이미 포함하고 있기 때문에 우리는 starter에 대한 의존성 추가만으로도 프로젝트를 시작하거나 새로운 기능을 추가할 수 있습니다.

 

예를들어, 기존에 aspectJ를 이용한 AOP를 이용하고 싶으면

org.springframework:spring-aop 의존성과 org.aspectj:aspectjweaver 의존성을 추가해서 사용했었지만

Spring Boot에선는 spring-boot-starter-aop 의존성만 추가하면 aspectJ를 사용하기 위한 모든 의존성 조합이 추가 됩니다.

의존성 조합의 간단한 예가 AOP였던 거고 좀 더 복잡한 의존성 조합을 보고 싶으시다면 다른 starter를 확인해 보시기 바랍니다. 

 

 

또다른 예시로 spring-boot-starter-jpa를 의존성 추가했을 때 아래와 같은 일을 해줍니다.

  • spring-aop, spring-jdbc 등의 의존성을 걸어준다.

  • classpath를 뒤져서 어떤 Database를 사용하는지 파악하고, 자동으로 entityManager를 구성해 준다.

  • 해당 모듈들 설정에 필요한 properties 설정을 제공한다. (Configuration Processor를 사용하면 효과 UP)

spring-boot-starter-data-jpa v2.1.7.RELEASE은 7개의 의존성 조합을 포함하고 있고 잘 살펴보시면 그 7개의 의존성 중에 또 다른 spring-boot-starter가 존재해서 실제는 7개보다 더 많은 의존성이 설정되어 있습니다.

또한 중복되어 문제가 되는 의존성에서 대해서는 exclusion 설정도 되어 있습니다.

 

즉, spring-boot-starter-jpa 모듈을 추가함으로써 아래의 7가지 의존성 조합에 대한 부분을 알아서 정리해주고 관리해줍니다.

<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-aop</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.transaction</groupId>
			<artifactId>javax.transaction-api</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.jboss.spec.javax.transaction</groupId>
					<artifactId>jboss-transaction-api_1.2_spec</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-jpa</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.aspectj</groupId>
					<artifactId>aspectjrt</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>jcl-over-slf4j</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aspects</artifactId>
		</dependency>
</dependencies>

 

spring-boot-starter-web 에 설정된 pom.xml 

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starters</artifactId>
    <version>2.2.1.RELEASE</version>
  </parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <version>2.2.1.RELEASE</version>
  <name>Spring Boot Web Starter</name>
  <description>Starter for building web, including RESTful, applications using Spring
		MVC. Uses Tomcat as the default embedded container</description>
  <url>https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web</url>
  <organization>
    <name>Pivotal Software, Inc.</name>
    <url>https://spring.io</url>
  </organization>
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>Pivotal</name>
      <email>info@pivotal.io</email>
      <organization>Pivotal Software, Inc.</organization>
      <organizationUrl>https://www.spring.io</organizationUrl>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:git://github.com/spring-projects/spring-boot.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/spring-projects/spring-boot.git</developerConnection>
    <url>https://github.com/spring-projects/spring-boot</url>
  </scm>
  <issueManagement>
    <system>Github</system>
    <url>https://github.com/spring-projects/spring-boot/issues</url>
  </issueManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
      <version>2.2.1.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-json</artifactId>
      <version>2.2.1.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <version>2.2.1.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
      <version>2.2.1.RELEASE</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <artifactId>tomcat-embed-el</artifactId>
          <groupId>org.apache.tomcat.embed</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>5.2.1.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>5.2.1.RELEASE</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

1. Spring Boot Starter는 우리가 찾아서 설정해야 하는 것들을 미리 작성해야 보다 쉽고 빠르고 정확하게 의존성 설정을 할 수 있게 해줍니다.

2. 프로젝트를 진행하면서, 공통적으로 사용하는 spring  설정을 모듈로 묶어놓고 사용할 수 있게 해줍니다.

3. 필요한 경우, 상위 프로젝트에서 얼마든지 설정을 덮어 쓸 수 있게 해줍니다.

 

 

spring-boot-starter 작성하기

https://supawer0728.github.io/2018/03/15/create-spring-boot-starter/


Spring Boot Starter Parent 

해당 의존성 조합간의 충돌문제가 없는 검증된 버전정보 조합을 제공

 

프로젝트 시작 시기에 다양한 라이브러리들을 사용하게되면 라이브러리 버전간의 충돌문제가 발생할 수 있습니다.

Sprign Boot의 starter가 의존성 조합을 제공해준다면 starter-parent는 해당 의존성 조합간의 충돌 문제가 없는 검증 된 버전정보 조합을 제공합니다.

spring-boot-starter-parent 2.1.7.RELEASE에서 제공하는 버전정보 조합은 Maven repository - spring-boot-stater-parent 혹은 GitHub - spring-boot-stater-parent 에서 확인 가능합니다.

우리는 아래와 같이 spring-boot-starter-parent 버전만 설정해도 수많은 라이브러리들의 버전충돌 문제를 피할 수 있습니다.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.7.RELEASE</version>
</parent>

<dependencies>
    ...(생략)

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
</dependencies>


특정 의존성이 버전을 변경하고자 한다면 아래와 같이 properties를 이용해서 해당 의존성 버전을 override하면 됩니다.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.7.RELEASE</version>
</parent>

<properties>
    <aspectj.version>1.9.4</aspectj.version>
</properties>

<dependencies>
    ...(생략)

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
</dependencies>

 

1. spring-boot-starter-parent 라이브러리를 사용해서 추가하는 라이브러리 모듈에 대한 버전을 가이드합니다.

2. <version> 태그를 추가하지 않아도 parent 에서 자동으로 처리해줍니다.

3. <version>에 대한 내용을 변경하고자 할 경우에는 <properties> 태그를 이용해서 변경, override 해줍니다.

 

728x90

 

나는 Java/ Maven Project 를 intelliJ IDEA에서 하고 있습니다.

그런데 내가 test 를 실행할려고 할때, 아래 그림과 같이 "Noting Here" 라는 메세지가 나오면서 실행이 안되네요.

그래서 한참을 찾다가 아래와 같은 해결책을 발견하여 공유합니다.

(I have a Java / maven project in IntelliJ IDEA, but when I try to run a test I got the message "Nothing Here")

 

1. 단계

- Preferences.. 에서 Plugins 탭에서 Gradle을 찾아보세요.

- Gradle이 설치되어 있는지 살펴보고 설치되어 Enable 되어 있다면 Disable 해주세요.

Apply 버튼을 클릭하시고 IntelliJ IDEA 를 Restart 합니다.

재 실행해서 보시면 아래와 같이 뜬다면 1단계는 성공 입니다~~!!!

 

2. 단계 : disabled_plugins.txt 를 찾아 아래 내용을 삭제합니다.

org.jetbrains.idea.gradle.ext
org.jetbrains.plugins.gradle
org.jetbrains.plugins.gradle.maven

 

전 여러개의 버전이 존재하는데 현재 2019.3 버전을 사용하고 있네요.

./Library/Preferences/IntelliJIdea2018.1/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2019.3/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2017.2/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2019.2/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2017.3/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2018.3/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2016.2/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2018.2/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2016.3/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2017.1/disabled_plugins.txt
./Library/Preferences/IntelliJIdea2019.1/disabled_plugins.txt

 

# vi  ./Library/Preferences/IntelliJIdea2019.3/disabled_plugins.txt

CFML Support
CloudFoundry
DevKit
GlassFish
IdeaVIM
JBoss
JSR45Plugin
Jetty
Resin
WebSphere
Weblogic
com.intellij.dmserver
com.intellij.drools
com.intellij.gradle
com.intellij.gwt
com.intellij.javaee.view
com.intellij.jboss.arquillian
com.intellij.jboss.core
com.intellij.seam
com.intellij.seam.pageflow
com.intellij.seam.pages
com.intellij.struts2
com.intellij.tapestry
com.intellij.uiDesigner
cucumber-groovy
org.intellij.grails
org.jetbrains.android
org.jetbrains.idea.gradle.ext  <<--- 찾았다 요놈!!!

 

그래도 해결 안된다면!!

마지막으로 위의 1,2단계로 해도 해결이 되지 않는다면 idea.log파일을 열어두고 해당 이슈에 대해 반복발생시켜서 살펴봐야 합니다.

(Help | Show Log In Explorer)

 

If it doesn't help, attach your idea.log file after reproducing the issue (Help | Show Log in Explorer).

 


참고 URL 

https://youtrack.jetbrains.com/issue/IDEA-228180?_ga=2.175130594.1707466865.1580292427-909525344.1568791489

https://stackoverflow.com/questions/59784808/cant-run-test-on-intellij-idea

+ Recent posts