자바 상용 기본 프로필
17188 단어 자바
mybatis.xml
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/usermanager" />
<property name="username" value="root" />
<property name="password" value="111111" />
dataSource>
environment>
environments>
<mappers>
<mapper class="com.dao.UserMapper"/>
mappers>
configuration>
spring.xml
<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"
xmlns:aop="http://www.springframework.org/schema/aop"
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.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<context:component-scan base-package="com.dao">context:component-scan>
<context:component-scan base-package="com.service">context:component-scan>
<context:component-scan base-package="com.web.controller">context:component-scan>
<context:property-placeholder location="classpath:jdbc.properties"/>
<bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}">property>
<property name="url" value="${jdbc.url}">property>
<property name="username" value="${jdbc.username}">property>
<property name="password" value="${jdbc.password}">property>
<property name="initialSize" value="${jdbc.initialSize}">property>
<property name="maxActive" value="${jdbc.maxActive}">property>
bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource">property>
bean>
beans>
클래스 로드 프로 세 스 코드
public class TestJDBCDemo {
public void func(Object... array){
for(Object data : array){
System.out.print(data + " ");
}
System.out.println();
}
public void testJDBC(){
//DriverManager Connection Statement( SQL ) Preparement( SQL)
}
public static int count(){
return 1%9;
}
public static void main(String[]args) throws Exception{
//System.out.println(count());
try {
Class> userclass = Class.forName("com.bean.User",true,new MyClassLoader());
Object user = (userclass.newInstance());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class MyClassLoader extends ClassLoader{
// , class
@Override
protected Class> findClass(String name1) throws ClassNotFoundException {
// TODO Auto-generated method stub
String root = "D:/";
//D:/com/bean/User.class
String path = root+name1.replace(".", "/")+".class";
File file = new File(path);
System.out.println("name:" + path);
byte[] buff = null;
try {
FileInputStream in = new FileInputStream(file);
buff = new byte[in.available()];
int len = in.read(buff);
in.close();
//defineClass class Class
Class> c = this.defineClass(name1, buff, 0, buff.length);
return c;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return super.findClass(path);
}
}
Tomcat 의 server.xml 설정
<Connector URIEncoding="UTF-8" acceptCount="600" connectionTimeout="20000" maxThreads="600" port="80" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"/>
<Connector SSLEnabled="true" clientAuth="false" keystoreFile="D:\tomcat.keystore" keystorePass="021602" maxThreads="150" port="8443" protocol="HTTP/1.1" scheme="https" secure="true" sslProtocol="TLS"/>
log4j(루트 디 렉 터 리 아래)
## debug
log4j.rootLogger=DEBUG,Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d{yyyy-MM-dd-HH\:mm\:ss,SSS} [%t] [%c] [%p] - %m%n
log4j.logger.com.mybatis=DEBUG /
## sql
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.