maven repository 구글검색후 들어가기
mariadb 쓰고 search
MariaDb Java Client 클릭
2.74버전 다운
내가사용할 코드 복사 ( 코드 클릭시 자동 복사됨)
복사된 코드
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.4</version>
</dependency>
복사한 코드 pom.xml 에
<dependencies> 뒤에 복붙하면 됩니다.
pom.xml 일부
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.zerock</groupId>
<artifactId>controller</artifactId>
<name>ex00</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<java-version>1.8</java-version>
<org.springframework-version>5.0.7.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
appServlet의
root-context.xml , servlet-context.xml
보통 root-context.xml 에 넣음
lib에 저장되는걸
maven이 해줌
maven repository 구글에 검색해서
들어가기
https://mvnrepository.com/
mariadb 검색
mariadb-java-client 들어가면
2.7.4 선택
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.4</version>
</dependency>
복사후
<dependencies> 뒤에 복붙
root-context 열어서
<bean id="dataSoruce" class="org.mariadb.jdbc.MariaDbPoolDataSource"></bean>
url, user, password 그냥 입력시 깃허브에 노출됨
그래서
db.propertys 파일을 읽어서 써야함
나는 jsp20211025 WEB-INF 안에 db.propertis 복사후
ex00 프로젝트에서
WEB-INF 안에 db.properties 파일 복붙
db.properties에
url=jdbc:mariadb://1.11.111.11:1111/test (내 ip 추가)
db.properties 내용 대략 보면
user=나의 user
password=나의비번
ip=1.11.111.11:1111 (대충 네 ip)
schema=test
url=jdbc:mariadb://1.11.111.11:1111/test //이거 나의 아이피로 추가
root-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:property-placeholder location="/WEB-INF/db.properties"/>
<!-- Root Context: defines shared resources visible to all other web components -->
<bean id="dataSource" class="org.mariadb.jdbc.MariaDbPoolDataSource">
<property name="url" value="${url}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="maxPoolSize" value="1"></property>
</bean>
</beans>
'연습하는것들 > 그날의 어떤것' 카테고리의 다른 글
spring Service 와 Dao에 관련 읽어보기 (0) | 2021.12.13 |
---|---|
2021-12-08 mybatis xml 4줄 (0) | 2021.12.08 |
12-06 <resources mapping="/resource/**" location="/resources/" /> (0) | 2021.12.06 |
12-06Controller05 미래의내가 궁금해서 알아보겠지 (0) | 2021.12.06 |
JDBC42Servlet 변화과정 (0) | 2021.12.02 |