首先,对,没错,你需要安装包以及破解的jar包
1.点击应用程序进行安装
选择安装路径,然后next,再然后出现的全勾选之后,next,然后点击install安装
安装成功后,
然后我们需要激活,不然的话,你只能用上10天半个月,所以需要破解,
1.将JetbrainsCrack-2.6.0.jar放入安装路径的lib包中
2.在bin目录下idea.exe.vmoptions和idea64.exe.vmoptions两个文件后分别换行追加:
-javaagent:D:/JetbrainsCrack-2.6.0.jar.. (注:此路径为你该jar包的绝对路径),
3,
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}
4.附加:如果使用中文包就将中文包目录下的resources_cn.jar放入lib目录下
如果不想再使用中文包,就再将lib目录下resources_cn.jar删除
接下来是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(); } } }