首先,对,没错,你须要安装包以及破解的jar包java
1.点击应用程序进行安装mysql
选择安装路径,而后next,再而后出现的全勾选以后,next,而后点击install安装sql
安装成功后,数据库
而后咱们须要激活,否则的话,你只能用上10天半个月,因此须要破解,apache
1.将JetbrainsCrack-2.6.0.jar放入安装路径的lib包中api
2.在bin目录下idea.exe.vmoptions和idea64.exe.vmoptions两个文件后分别换行追加:
-javaagent:D:/JetbrainsCrack-2.6.0.jar.. (注:此路径为你该jar包的绝对路径),session
3,mybatis
3.运行idea程序(32位系统运行idea.exe,64位系统运行idea64.exe)
在注册页面选中中间的选项,在文本框中输入:
ThisCrackLicenseId-{
"licenseId":"ThisCrackLicenseId",
"licenseeName":"Rover12421",
"assigneeName":"",
"assigneeEmail":"rover12421@163.com",
"licenseRestriction":"For Rover12421 Crack, Only Test! Please support genuine!!!",
"checkConcurrentUse":false,
"products":[
{"code":"II","paidUpTo":"2099-12-31"},
{"code":"DM","paidUpTo":"2099-12-31"},
{"code":"AC","paidUpTo":"2099-12-31"},
{"code":"RS0","paidUpTo":"2099-12-31"},
{"code":"WS","paidUpTo":"2099-12-31"},
{"code":"DPN","paidUpTo":"2099-12-31"},
{"code":"RC","paidUpTo":"2099-12-31"},
{"code":"PS","paidUpTo":"2099-12-31"},
{"code":"DC","paidUpTo":"2099-12-31"},
{"code":"RM","paidUpTo":"2099-12-31"},
{"code":"CL","paidUpTo":"2099-12-31"},
{"code":"PC","paidUpTo":"2099-12-31"}
],
"hash":"2911276/0",
"gracePeriodDays":7,
"autoProlongated":false}app
4.附加:若是使用中文包就将中文包目录下的resources_cn.jar放入lib目录下
若是不想再使用中文包,就再将lib目录下resources_cn.jar删除ide
接下来是IDEA的基本操做,
建立java项目点击Create project from template,点击java Hello World 建立项目,选择项目路径完成建立
编写以前咱们须要9个jar包文件
asm-3.3.1.jar 操做java字节码的类库
cglib-2.2.2.jar 用来动态集成Java类或实现接口
commons-logging-1.1.1.jar 用于通用日志处理
javassist-3.17.1-GA.jar 分析·编辑和建立java字节码的类库
log4j-1.2.17.jar 日志系统
slf4j-api-1.7.5.jar 日志系统的封装,对外提供统一的api接口
slf4j-log4j12-1.7.5.jar slf4对log4j的相应驱动,完成slf4j绑定log4j
以及链接数据库的jar包
点击new建立文件夹lib把这些jar包放入,点击项目右键open module setting 的最后一个,点击+号,找到jar包而后ok
建立config.xml文件
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <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:/// y2167"/> <property name="username" value="root"/> <property name="password" value=""/> </dataSource> </environment> </environments> <mappers> <mapper resource="cn/dao/IBookDao.xml"/> </mappers> </configuration>
而后建立与数据库对应的实体类
public class Book { private Integer bookID; private String bookName; private String bookAuthor; private int bookPrice; public Integer getBookID() { return bookID; } public void setBookID(Integer bookID) { this.bookID = bookID; } public String getBookName() { return bookName; } public void setBookName(String bookName) { this.bookName = bookName; } public String getBookAuthor() { return bookAuthor; } public void setBookAuthor(String bookAuthor) { this.bookAuthor = bookAuthor; } public int getBookPrice() { return bookPrice; } public void setBookPrice(int bookPrice) { this.bookPrice = bookPrice; } }
而后建立dao层
package cn.dao; import cn.entity.Book; import java.util.List; /** * Created by Administrator on 2018/1/27. */ public interface IBookDao { public List<Book> findAllBook(); }
而后是配置与dao相同名的xml文件
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="cn.dao.IBookDao"> <select id="findAllBook" resultType="cn.entity.Book"> select * from book </select> </mapper>
其中的namespace指dao的路径,建议使用快捷键右键该dao文件copy reference,而后粘贴
id是方法名,resultType是实体类的路径,同上方法,
而后是test类,实现类
package cn.test; import cn.entity.Book; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import java.io.IOException; import java.io.InputStream; import java.util.List; /** * Created by Administrator on 2018/1/27. */ public class Test { public static void main(String[] args) { String path = "mybatis-config.xml"; try { InputStream is = Resources.getResourceAsStream(path); SqlSessionFactoryBuilder build = new SqlSessionFactoryBuilder(); SqlSessionFactory factory = build.build(is); SqlSession session = factory.openSession(); List<Book> list = session.selectList("findAllBook"); for (Book book : list) { System.out.println(book.getBookName()); } session.close(); }catch(IOException e){ e.printStackTrace(); } } }