maven,IDEA多模块项目,啊,快要疯了,好吧,又是一个笔记
好吧,根据记忆一步一步试吧,实在不行,继续折腾;我这里用的是mac版的IDEA,不过和windows版的弄法是一样的,只是有一些按键的位置不同而已(后来发现好像没有- -!)
先创建一个空项目先~!
1、打开IDEA,选择Create New Project;
2、选择左边的Empty Project;再选择右边的Empty Project;然后Next
3、Next后出现以下界面,写入项目名称,项目路径;然后点Finish;
4、点了Finish后,会出现下面的界面(我的是2016.3.5的IDEA,不知道其他版本的有没有这个界面,反正有没有也没有影响,随他去吧^_^);不管他,点OK也行,点Cancel也行(反正我是瞎点,两个都点过);
好!接下来开始项目搭建!!
创建父级项目:store-parent 后面的都继承这个项目
1、点击File--->New--->Module
2、在弹出的New Module窗口,选择如下图选项,然后Next
3、填写组织名GroupId,项目名称ArtifactId,然后Next;至于Version嘛,不要动它就好咯;呃...项目名称,在下面还有一步需要写一个名称,会自己把 ‘‘-’’给消掉,我也没深究,只是自己手动补上‘‘-’’这个东西,想加就加,不想加就不加,反正规范,我也不知道合不合适,随我自己喜欢而已
4、点了Next后,出现maven的相关页面了,一直说maven,maven的,刚开始我在这里乱来,害了好几条头发细胞;选好自己下载好的maven,我不知道用IDEA自带的maven行不行,反正我用是不行,M了个几的,弄了好久,最后还是自己下载,配置好之后才行;选好了,就Next吧
5、上面说到项目名称的时候,下面有一个地方会消掉‘‘-’’,就是这里了,点了Next后,出现下面的界面,store和project之间的 ‘‘-’’是我自己手动加上去的,那一竖,是我的光标,无视吧无视吧。看个人喜欢了,我强迫症,有病,放弃治疗了,没法子;选好自己项目的路径,Finish吧
Finish之后,等咯,等项目结构生成完毕吧(又想起了第一次建maven的时候被墙的傻逼等待- -);项目目录生成完毕后,改pom文件吧;parent是
项目的父项目,管理jar包啊、版本啊,呃.. 聚合...聚合什么来着...唉哟,不管啦,反正要把打包方式改成pom;
pom文件的代码:
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 <groupId>store.project</groupId> 5 <artifactId>store-parent</artifactId> 6 <version>1.0-SNAPSHOT</version> 7 <packaging>pom</packaging><!--以pom方式打包--> 8 9 <!-- 集中定义依赖版本号 --> 10 <properties> 11 <junit.version>4.12</junit.version> 12 <spring.version>4.1.3.RELEASE</spring.version> 13 <mybatis.version>3.2.8</mybatis.version> 14 <mybatis.spring.version>1.2.2</mybatis.spring.version> 15 <mybatis.paginator.version>1.2.15</mybatis.paginator.version> 16 <mysql.version>5.1.32</mysql.version> 17 <slf4j.version>1.6.4</slf4j.version> 18 <jackson.version>2.4.2</jackson.version> 19 <druid.version>1.0.9</druid.version> 20 <httpclient.version>4.3.5</httpclient.version> 21 <jstl.version>1.2</jstl.version> 22 <servlet-api.version>2.5</servlet-api.version> 23 <jsp-api.version>2.0</jsp-api.version> 24 <joda-time.version>2.5</joda-time.version> 25 <commons-lang3.version>3.3.2</commons-lang3.version> 26 <commons-io.version>1.3.2</commons-io.version> 27 <commons-net.version>3.3</commons-net.version> 28 <pagehelper.version>3.4.2-fix</pagehelper.version> 29 <jsqlparser.version>0.9.1</jsqlparser.version> 30 <commons-fileupload.version>1.3.1</commons-fileupload.version> 31 <jedis.version>2.7.2</jedis.version> 32 <solrj.version>4.10.3</solrj.version> 33 <freemarker.version>2.3.23</freemarker.version> 34 <quartz.version>2.2.2</quartz.version> 35 </properties> 36 <dependencyManagement> 37 <dependencies> 38 <!-- 时间操作 --> 39 <dependency> 40 <groupId>joda-time</groupId> 41 <artifactId>joda-time</artifactId> 42 <version>${joda-time.version}</version> 43 </dependency> 44 <!-- Apache --> 45 <dependency> 46 <groupId>org.apache.commons</groupId> 47 <artifactId>commons-lang3</artifactId> 48 <version>${commons-lang3.version}</version> 49 </dependency> 50 <dependency> 51 <groupId>org.apache.commons</groupId> 52 <artifactId>commons-io</artifactId> 53 <version>${commons-io.version}</version> 54 </dependency> 55 <dependency> 56 <groupId>commons-net</groupId> 57 <artifactId>commons-net</artifactId> 58 <version>${commons-net.version}</version> 59 </dependency> 60 <!-- Jackson Json处理 --> 61 <dependency> 62 <groupId>com.fasterxml.jackson.core</groupId> 63 <artifactId>jackson-databind</artifactId> 64 <version>${jackson.version}</version> 65 </dependency> 66 <!-- httpclient --> 67 <dependency> 68 <groupId>org.apache.httpcomponents</groupId> 69 <artifactId>httpclient</artifactId> 70 <version>${httpclient.version}</version> 71 </dependency> 72 <!-- junit --> 73 <dependency> 74 <groupId>junit</groupId> 75 <artifactId>junit</artifactId> 76 <version>${junit.version}</version> 77 <scope>test</scope> 78 </dependency> 79 <!-- 日志处理 --> 80 <dependency> 81 <groupId>org.slf4j</groupId> 82 <artifactId>slf4j-log4j12</artifactId> 83 <version>${slf4j.version}</version> 84 </dependency> 85 <!-- Mybatis --> 86 <dependency> 87 <groupId>org.mybatis</groupId> 88 <artifactId>mybatis</artifactId> 89 <version>${mybatis.version}</version> 90 </dependency> 91 <dependency> 92 <groupId>org.mybatis</groupId> 93 <artifactId>mybatis-spring</artifactId> 94 <version>${mybatis.spring.version}</version> 95 </dependency> 96 <dependency> 97 <groupId>com.github.miemiedev</groupId> 98 <artifactId>mybatis-paginator</artifactId> 99 <version>${mybatis.paginator.version}</version> 100 </dependency> 101 <dependency> 102 <groupId>com.github.pagehelper</groupId> 103 <artifactId>pagehelper</artifactId> 104 <version>${pagehelper.version}</version> 105 </dependency> 106 <!-- MySql --> 107 <dependency> 108 <groupId>mysql</groupId> 109 <artifactId>mysql-connector-java</artifactId> 110 <version>${mysql.version}</version> 111 </dependency> 112 <!-- 连接池 --> 113 <dependency> 114 <groupId>com.alibaba</groupId> 115 <artifactId>druid</artifactId> 116 <version>${druid.version}</version> 117 </dependency> 118 <!-- Spring --> 119 <dependency> 120 <groupId>org.springframework</groupId> 121 <artifactId>spring-context</artifactId> 122 <version>${spring.version}</version> 123 </dependency> 124 <dependency> 125 <groupId>org.springframework</groupId> 126 <artifactId>spring-beans</artifactId> 127 <version>${spring.version}</version> 128 </dependency> 129 <dependency> 130 <groupId>org.springframework</groupId> 131 <artifactId>spring-webmvc</artifactId> 132 <version>${spring.version}</version> 133 </dependency> 134 <dependency> 135 <groupId>org.springframework</groupId> 136 <artifactId>spring-jdbc</artifactId> 137 <version>${spring.version}</version> 138 </dependency> 139 <dependency> 140 <groupId>org.springframework</groupId> 141 <artifactId>spring-aspects</artifactId> 142 <version>${spring.version}</version> 143 </dependency> 144 <dependency> 145 <groupId>org.springframework</groupId> 146 <artifactId>spring-context-support</artifactId> 147 <version>${spring.version}</version> 148 </dependency> 149 <!-- JSP相关 --> 150 <dependency> 151 <groupId>jstl</groupId> 152 <artifactId>jstl</artifactId> 153 <version>${jstl.version}</version> 154 </dependency> 155 <dependency> 156 <groupId>javax.servlet</groupId> 157 <artifactId>servlet-api</artifactId> 158 <version>${servlet-api.version}</version> 159 <scope>provided</scope> 160 </dependency> 161 <dependency> 162 <groupId>javax.servlet</groupId> 163 <artifactId>jsp-api</artifactId> 164 <version>${jsp-api.version}</version> 165 <scope>provided</scope> 166 </dependency> 167 <!-- 文件上传 --> 168 <dependency> 169 <groupId>commons-fileupload</groupId> 170 <artifactId>commons-fileupload</artifactId> 171 <version>${commons-fileupload.version}</version> 172 </dependency> 195 </dependencies> 196 </dependencyManagement> 197 198 <build> 199 <finalName>${project.artifactId}</finalName> 200 <plugins> 201 <!-- 资源文件拷贝 --> 202 <plugin> 203 <groupId>org.apache.maven.plugins</groupId> 204 <artifactId>maven-resources-plugin</artifactId> 205 <version>2.7</version> 206 <configuration> 207 <encoding>UTF-8</encoding> 208 </configuration> 209 </plugin> 210 <!-- java编译插件 --> 211 <plugin> 212 <groupId>org.apache.maven.plugins</groupId> 213 <artifactId>maven-compiler-plugin</artifactId> 214 <version>3.2</version> 215 <configuration> 216 <source>1.7</source> 217 <target>1.7</target> 218 <encoding>UTF-8</encoding> 219 </configuration> 220 </plugin> 221 </plugins> 222 <pluginManagement> 223 <plugins> 224 <!-- 配置Tomcat插件 --> 225 <plugin> 226 <groupId>org.apache.tomcat.maven</groupId> 227 <artifactId>tomcat7-maven-plugin</artifactId> 228 <version>2.2</version> 229 </plugin> 230 </plugins> 231 </pluginManagement> 232 </build> 233 </project>
父级项目,嗯,建完了,对建完了(反正是笔记@[email protected])
好咯,接下来是公共项目咯 起名:store-common; 继承父项目store-parent;
1、和建parent项目一样,File--->New--->Module
2、选完之后,这里可就不同了,要看清楚看清楚哦,注意看3的那个位置哈;详情如看下图;OK,Next!
3、Next之后,要选好继承关系,Add as module to 这里得选择none;就是不将项目加入别的项目里面去,项目结构分层清淅嘛,必须的,然后Next吧!
4、选择maven的本地仓库,这个老生长谈啦,Next
5、项目路径,跟parent一样,只是后面的名字是common,哦,强迫症,手动加‘‘-’’ OK Finish!
6、Finish后,等待项目目录生成完毕吧,不过,这里有一个情况,就是在common的java目录下,有一个MyPortlet类,在项目建好之后呢,Build或者在Maven Project里面install的时候,会报错,我这里是少包了,但是呢,那个类,项目不需要用,我很粗暴的,删!包括store.project包都一起,删!
7、好啦,在这里,继续改pom文件,common呢,跟parent有所不同,它的打包形式是jar;所以,改!
pom代码如下:
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 3 <parent> 4 <artifactId>store-parent</artifactId> 5 <groupId>store.project</groupId> 6 <version>1.0-SNAPSHOT</version> 7 <relativePath>../store-parent/pom.xml</relativePath> 8 </parent> 9 <modelVersion>4.0.0</modelVersion> 10 <artifactId>store-common</artifactId> 11 <packaging>jar</packaging> <!--更改打包形式为jar--> 12 13 14 <name>store-common</name> 15 <url>http://maven.apache.org</url> 16 17 <!-- 添加依赖 --> 18 <dependencies> 19 <!-- 时间操作 --> 20 <dependency> 21 <groupId>joda-time</groupId> 22 <artifactId>joda-time</artifactId> 23 </dependency> 24 <!-- Apache --> 25 <dependency> 26 <groupId>org.apache.commons</groupId> 27 <artifactId>commons-lang3</artifactId> 28 </dependency> 29 <dependency> 30 <groupId>org.apache.commons</groupId> 31 <artifactId>commons-io</artifactId> 32 </dependency> 33 <dependency> 34 <groupId>commons-net</groupId> 35 <artifactId>commons-net</artifactId> 36 </dependency> 37 <!-- Jackson Json --> 38 <dependency> 39 <groupId>com.fasterxml.jackson.core</groupId> 40 <artifactId>jackson-databind</artifactId> 41 </dependency> 42 <!-- httpclient --> 43 <dependency> 44 <groupId>org.apache.httpcomponents</groupId> 45 <artifactId>httpclient</artifactId> 46 </dependency> 47 <!-- junit --> 48 <dependency> 49 <groupId>junit</groupId> 50 <artifactId>junit</artifactId> 51 </dependency> 52 <!-- 日志处理 --> 53 <dependency> 54 <groupId>org.slf4j</groupId> 55 <artifactId>slf4j-log4j12</artifactId> 56 </dependency> 57 </dependencies> 58 </project>
OK!又一个项目建好了,我去,写这东西,原来这么辛苦,比玩代码还花脑浆糊- - !好吧,继续;
接下来:store-manager;和store-common的创建一样;不过,打包方式是和parent一样的,都是pom形式,来,走起
1、File--->New--->Module; 然后 Next!
2、继承parent,然后Add as module to 继续是none;Next!
3、选择Maven,都不用动咯,跟上面一样;Next!
4、选择路径,这里一样,强迫症,手动加上‘‘-’’,没有强迫症的,顺心意。哈哈;Finish!
5、老活了,等项目目录生成完毕!跟common一样,删MyPortlet
6、更改pom文件,把打包形式改成pom
pom代码:
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 3 <parent> 4 <artifactId>store-parent</artifactId> 5 <groupId>store.project</groupId> 6 <version>1.0-SNAPSHOT</version> 7 <relativePath>../store-parent/pom.xml</relativePath> 8 </parent> 9 <modelVersion>4.0.0</modelVersion> 10 <artifactId>store-manager</artifactId> 11 <packaging>pom</packaging><!--打包方式改成pom--> 12 13 <name>store-manager</name> 14 <url>http://maven.apache.org</url> 15 16 <!-- 添加公共项目的依赖 --> 17 <dependencies> 18 <dependency> 19 <groupId>store.project</groupId> 20 <artifactId>store-common</artifactId> 21 <version>1.0-SNAPSHOT</version> 22 </dependency> 23 24 <!-- JSP相关 --> 25 <dependency> 26 <groupId>jstl</groupId> 27 <artifactId>jstl</artifactId> 28 </dependency> 29 <dependency> 30 <groupId>javax.servlet</groupId> 31 <artifactId>servlet-api</artifactId> 32 <scope>provided</scope> 33 </dependency> 34 <dependency> 35 <groupId>javax.servlet</groupId> 36 <artifactId>jsp-api</artifactId> 37 <scope>provided</scope> 38 </dependency> 39 <!-- 文件上传 --> 40 <dependency> 41 <groupId>commons-fileupload</groupId> 42 <artifactId>commons-fileupload</artifactId> 43 </dependency> 44 </dependencies> 45 </project>
OK 又一个里程碑啊!抽根烟..哦...不,咬根牙签;继续!
接下来是manager里面的pojo了,一开始我在想pojo是什么鬼,实体类嘛,差点蠢哭!
来吧,折磨吧
起名:store-manager-pojo
1、这个时候的新建和上面的都不一样了,这个时候要在store-manager项目上右击鼠标--->New--->Module;
2、这个时候的选项,要注意一下了,好叻,看下图;然后,继续Next!
3、在这个地方呢,和前面有所不同,pojo是继承在manager的,同时呢,也是添加到manager项目下面去的,要注意了哈,仔细看好下图哦!哟西,Next!
4、选择maven路径,唉哟我去,又是重复的活,无语凝焉,目望显示器,Next!
5、又到了选路径的时候了,号外号外,划重点了,这里路径如果你写完Module name之后直接Finish,那么,你哭吧,反正我哭过。一定得在store-manger后面加上/,再加Model name,像下图一样,要不然,你哭吧,反正我看不到。呀哈!Finish吧!骚年?李白?什么鬼!完成!
6、简单的工作重复做,重复吧,少年,修改pom文件,将打包形式改成jar,不过,我的到这里,,自然就是jar的了,我当时好像import了什么,不是也没影响,一字记之曰,改嘛
pom代码:
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <parent> 4 <artifactId>store-manager</artifactId> 5 <groupId>store.project</groupId> 6 <version>1.0-SNAPSHOT</version> 7 </parent> 8 <modelVersion>4.0.0</modelVersion> 9 10 <artifactId>store-manager-pojo</artifactId> 11 <packaging>jar</packaging><!--打包形式改成jar--> 12 13 <name>store-manager-pojo</name> 14 <url>http://maven.apache.org</url> 15 16 <properties> 17 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 18 </properties> 19 20 <dependencies> 21 <dependency> 22 <groupId>junit</groupId> 23 <artifactId>junit</artifactId> 24 <version>3.8.1</version> 25 <scope>test</scope> 26 </dependency> 27 </dependencies> 28 </project>
POJO完成了,那么DAO咯,来吧 :store-manager-dao
和pojo一样鬼样,在manager上右击--->New--->Module 。唉我去,又是重复的,放图,不放图,放图,好吧,放图(我要简化,我要偷懒),继续!
1、
2、
3、
4、
5、
6、pom代码:
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <parent> 4 <artifactId>store-manager</artifactId> 5 <groupId>store.project</groupId> 6 <version>1.0-SNAPSHOT</version> 7 </parent> 8 <modelVersion>4.0.0</modelVersion> 9 10 <artifactId>store-manager-dao</artifactId> 11 <packaging>jar</packaging><!--打包形式改成jar--> 12 13 <name>store-manager-dao</name> 14 <url>http://maven.apache.org</url> 15 16 <properties> 17 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 18 </properties> 19 20 <!-- 添加依赖 --> 21 <dependencies> 22 <dependency> 23 <groupId>store.project</groupId> 24 <artifactId>store-manager-pojo</artifactId> 25 <version>1.0-SNAPSHOT</version> 26 </dependency> 27 <!-- Mybatis --> 28 <dependency> 29 <groupId>org.mybatis</groupId> 30 <artifactId>mybatis</artifactId> 31 </dependency> 32 <dependency> 33 <groupId>org.mybatis</groupId> 34 <artifactId>mybatis-spring</artifactId> 35 </dependency> 36 <dependency> 37 <groupId>com.github.miemiedev</groupId> 38 <artifactId>mybatis-paginator</artifactId> 39 </dependency> 40 <dependency> 41 <groupId>com.github.pagehelper</groupId> 42 <artifactId>pagehelper</artifactId> 43 </dependency> 44 <!-- MySql --> 45 <dependency> 46 <groupId>mysql</groupId> 47 <artifactId>mysql-connector-java</artifactId> 48 </dependency> 49 <!-- 连接池 --> 50 <dependency> 51 <groupId>com.alibaba</groupId> 52 <artifactId>druid</artifactId> 53 </dependency> 54 </dependencies> 55 </project>
继续:store-manager-service
1、
2、
3、
4、
5、路径的坑,得填
6、pom代码:
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <parent> 4 <artifactId>store-manager</artifactId> 5 <groupId>store.project</groupId> 6 <version>1.0-SNAPSHOT</version> 7 </parent> 8 <modelVersion>4.0.0</modelVersion> 9 10 <artifactId>store-manager-service</artifactId> 11 <packaging>jar</packaging><!--打包形式改成jar--> 12 13 14 <name>store-manager-service</name> 15 <url>http://maven.apache.org</url> 16 17 <properties> 18 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 19 </properties> 20 21 <dependencies> 22 <dependency> 23 <groupId>store.project</groupId> 24 <artifactId>store-manager-dao</artifactId> 25 <version>1.0-SNAPSHOT</version> 26 </dependency> 27 <dependency> 28 <groupId>org.springframework</groupId> 29 <artifactId>spring-context</artifactId> 30 </dependency> 31 <dependency> 32 <groupId>org.springframework</groupId> 33 <artifactId>spring-beans</artifactId> 34 </dependency> 35 <dependency> 36 <groupId>org.springframework</groupId> 37 <artifactId>spring-webmvc</artifactId> 38 </dependency> 39 <dependency> 40 <groupId>org.springframework</groupId> 41 <artifactId>spring-jdbc</artifactId> 42 </dependency> 43 <dependency> 44 <groupId>org.springframework</groupId> 45 <artifactId>spring-aspects</artifactId> 46 </dependency> 47 <dependency> 48 <groupId>org.springframework</groupId> 49 <artifactId>spring-context-support</artifactId> 50 </dependency> 51 </dependencies> 52 </project>
现在,到了最后一个了,这一个,还真不能偷懒了,store-manager-web走起
store-manager-web
1、依然是在manager上右击--->New--->Module
2、哪,这个地方要注意了,在这里,选择的是archetype-webapp,跟上面的不一样,要看仔细哦!~
3、Next,没毛病
4、继续,还是没毛病
5、路径的坑,还是得坑,要不然,还真就有毛病了 0.0!
6、好吧,改pom吧,web项目以war形式打包
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 3 <parent> 4 <artifactId>store-manager</artifactId> 5 <groupId>store.project</groupId> 6 <version>1.0-SNAPSHOT</version> 7 </parent> 8 <modelVersion>4.0.0</modelVersion> 9 <artifactId>store-manager-web</artifactId> 10 <packaging>war</packaging><!--这里是war,不可搞错了哟--> 11 12 13 <name>store-manager-web Maven Webapp</name> 14 <url>http://maven.apache.org</url> 15 <dependencies> 16 <dependency> 17 <groupId>junit</groupId> 18 <artifactId>junit</artifactId> 19 <version>3.8.1</version> 20 <scope>test</scope> 21 </dependency> 22 </dependencies> 23 <build> 24 <finalName>store-manager-web</finalName> 25 </build> 26 </project>
哈,终于到这了,好叻,要让项目跑起来,还得配Maven Tomcat Plugin;唉哟喂... 累呀,来吧
开始,哇哈哈!
1、点击我们平时做web的时候配Tomcat的地方;点击Edit Configurations;
2、点击选完之后,按着下图来,选择Maven
3、选完,接着OK以后,出现下图,写好名字,选好路径,写好命令;唉我去,感觉我好啰嗦- -!!;
4、写完,点击OK,好啦,你就会看到下面这个好看的东西了,然后点击红圈里的那个绿三角吧,运行项目
然后,然后,我去,common咋啦,好咯,想起来了,这货还没有打包;
5、打包store-common,选中Maven Projects,如下图找出common的install;双击它吧,用力点。噢~!
6、看到下面这个,就是成功了;还记得上面有说到删除 MyPortlet 类么。我就是没有删,结果报了半天错,泥煤的,我又是个小白,不停的导这个包那个包的,折腾了几次,粗暴的删掉。好吧,世界好了$_$
好,我们接着再来运行我们的宝贝项目
哎~我了个去,这个还得打包,好,打包parent! 跟打包common是一样的了,啊~~~就不重复了。这笔记写的,我应该也没那么笨,如果忘了再看,到这了,应该也会了- -!!
打包完之后,接着运行项目;然后,这是什么鬼0.0。实说,我真在这里懵逼了好久,看不懂,也不知道怎么查啊。最后,打了个电话;结果被那位小伙伴笑了半天,说我白学了,manager项目的pom文件里面配tomcat插件;好吧,我是白学了- -!!
在store-manger的pom文件里,嗯,想起来上面说的聚合什么什么的,聚合工程,对,聚合工程,呃...跑歪了!在store-manger的pom文件里,把tomcat配好;
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 3 <parent> 4 <artifactId>store-parent</artifactId> 5 <groupId>store.project</groupId> 6 <version>1.0-SNAPSHOT</version> 7 <relativePath>../store-parent/pom.xml</relativePath> 8 </parent> 9 <modelVersion>4.0.0</modelVersion> 10 <artifactId>store-manager</artifactId> 11 <packaging>pom</packaging><!--打包方式改成pom--> 12 13 <name>store-manager</name> 14 <url>http://maven.apache.org</url> 15 16 <modules> 17 <module>store-manager-pojo</module> 18 <module>store-manager-dao</module> 19 <module>store-manager-service</module> 20 <module>store-manager-web</module> 21 </modules> 22 23 <!-- 添加和公共基项目的依赖 --> 24 <dependencies> 25 <dependency> 26 <groupId>store.project</groupId> 27 <artifactId>store-common</artifactId> 28 <version>1.0-SNAPSHOT</version> 29 </dependency> 30 31 <!-- JSP相关 --> 32 <dependency> 33 <groupId>jstl</groupId> 34 <artifactId>jstl</artifactId> 35 </dependency> 36 <dependency> 37 <groupId>javax.servlet</groupId> 38 <artifactId>servlet-api</artifactId> 39 <scope>provided</scope> 40 </dependency> 41 <dependency> 42 <groupId>javax.servlet</groupId> 43 <artifactId>jsp-api</artifactId> 44 <scope>provided</scope> 45 </dependency> 46 <!-- 文件上传组件 --> 47 <dependency> 48 <groupId>commons-fileupload</groupId> 49 <artifactId>commons-fileupload</artifactId> 50 </dependency> 51 </dependencies> 52 53 <!-- 添加tomcat插件 --> <!--要加的东西在这里哈--> 54 <build> 55 <plugins> 56 <plugin> 57 <groupId>org.apache.tomcat.maven</groupId> 58 <artifactId>tomcat7-maven-plugin</artifactId> 59 <configuration> 60 <port>8080</port> 61 <path>/</path> 62 </configuration> 63 </plugin> 64 </plugins> 65 </build> 66 67 </project>
运行...运行...OK,没学跑先学的飞,到现在,项目,起来了。
然后,,见到了进新手村的第一个NPC
最后,项目搭建完的结构是下面这样子了
好啦,跑是跑通了,后续还有什么问题,慢慢再摸吧,这笔记写的又臭又长,估计就算我忘了,自己回头来看也会对着自己说一句,写的什么傻逼东西哦;不过没办法,水平有限,刚进入到java这个坑。
号外号外:只是我自己做为我自己的笔记记录;
申请申请:只是我自己做为我自己的笔记记录;
注释注释:只是我自己做为我自己的笔记记录; 重要的事说三遍!!!
有笔记就将就吧。睡觉睡觉。写这鬼东西,精神消耗的累成狗!,不,狗都比我幸福- -!