[英]Converting Eclipse Maven Project into Eclipse Maven Dynamic Web Project
[英]converting project to maven using eclipse
我正在尝试将当前应用程序转换为Maven。 我将代码分为不同的模块。
它是一个具有
Controller package
Model package
services packages
DAO packages
mybatis package which has interface to interact with database
WEB-INF Folder which contains all jsps inside /jsp folder
我创建了不同的模块,然后创建了一个核心模块
service package
DAO Package
src/main/webapp/WEB-INF
我创建了具有所有模型类的Model模块,并且能够成功编译它。
现在我正在尝试编译mybatis软件包,这给了我错误
/home/.../mybatis/db/mybatis/dao/usersmapper.java :[7,54] error:
package com.mycom.myproject.mybatis.db.mybatis.model does not exist
因为已经使用模型模块创建了usersmapper.class。
所以我没有弄错我在做什么。
我的主要pom.xml是
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproject</groupId>
<artifactId>mainapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>mainapp</name>
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
</properties>
<dependencies>
<!--Joda time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time-jsptags</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>model</module>
<module>core</module>
<module>mybatis</module>
</modules>
我的模型pom是我可以编译的
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mainapp</artifactId>
<groupId>com.myproject</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproject</groupId>
<artifactId>model</artifactId>
<packaging>jar</packaging>
<name>model</name>
我无法编译的mybatis pom是
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mainapp</artifactId>
<groupId>com.myproject</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproject</groupId>
<artifactId>mybatis</artifactId>
<packaging>jar</packaging>
<name>mybatis</name>
<dependencies>
<!-- mybaties -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
如果您需要更多信息,请告诉我。
您的mybatis
模块缺少对模型项目的依赖。 依赖关系在模块的编译类路径中基本上包括另一个项目的类。
因此,包括:
<dependency>
<groupId>com.myproject</groupId>
<artifactId>model</artifactId>
<version>${project.version}</version>
</dependency>
在mybatis
模块中,您应该一切顺利。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.