java - cannot import org.apache.poi in spring so not able to compile -


i trying import excel data in desktop mysql database not able parse excel file not able import org.apache.poi have given pom file also, in have included org.apache.poi dependency still not able import because of not able poifsfilesystem,hssfworkbook,etc use

my java code:

    public static void main( string[] args )         {              fileinputstream input = new fileinputstream("/users/desktop/file.xlsx");               poifsfilesystem fs = new poifsfilesystem( input );               hssfworkbook wb = new hssfworkbook(fs);               hssfsheet sheet = wb.getsheetat(0);                hssfrow row;                  applicationcontext appcontext =                        new classpathxmlapplicationcontext("resources/spring/config/beanlocations.xml");                      stockbo stockbo = (stockbo)appcontext.getbean("stockbo");                      int row1 = 1;                     /** insert **/                     stock stock = new stock();  for(int i=1; i<=sheet.getlastrownum(); i++)                 {                       employee employee=new employee();                     row = sheet.getrow(i);                       stock.setrow(row1);                     stock.setsource(string.valueof(row.getcell(0).getrichstringcellvalue()));                     stock.setdestination(string.valueof(row.getcell(1).getrichstringcellvalue()));                     stock.setprotocol(string.valueof(row.getcell(2).getrichstringcellvalue()));                     stock.setport("");                     stockbo.save(stock); }             system.out.println( "hello world!" );         } 

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>xl</groupid>       <artifactid>xl</artifactid>       <version>0.0.1-snapshot</version>       <packaging>jar</packaging>        <name>xl</name>       <url>http://maven.apache.org</url>        <properties>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>       </properties>        <dependencies>           <dependency>               <groupid>junit</groupid>               <artifactid>junit</artifactid>               <version>3.8.1</version>               <scope>test</scope>           </dependency>            <!-- spring framework -->           <dependency>               <groupid>org.springframework</groupid>               <artifactid>spring</artifactid>               <version>2.5.6</version>           </dependency>            <!-- spring aop dependency -->           <dependency>               <groupid>cglib</groupid>               <artifactid>cglib</artifactid>               <version>2.2</version>           </dependency>            <!-- mysql database driver -->           <dependency>               <groupid>mysql</groupid>               <artifactid>mysql-connector-java</artifactid>               <version>5.1.9</version>           </dependency>            <!-- hibernate framework -->           <dependency>               <groupid>org.hibernate</groupid>               <artifactid>hibernate</artifactid>               <version>3.2.3.ga</version>           </dependency>                 <!-- hibernate library dependecy start -->           <dependency>               <groupid>dom4j</groupid>               <artifactid>dom4j</artifactid>               <version>1.6.1</version>           </dependency>            <dependency>               <groupid>commons-logging</groupid>               <artifactid>commons-logging</artifactid>               <version>1.1.1</version>           </dependency>            <dependency>               <groupid>commons-collections</groupid>               <artifactid>commons-collections</artifactid>               <version>3.2.1</version>           </dependency>            <dependency>               <groupid>antlr</groupid>               <artifactid>antlr</artifactid>               <version>2.7.7</version>           </dependency>            <!-- hibernate library dependecy end -->           <dependency>               <groupid>javax.transaction</groupid>               <artifactid>jta</artifactid>               <version>1.1</version>           </dependency>           <dependency>               <groupid>org.springframework</groupid>               <artifactid>spring-orm</artifactid>               <version>${spring.version}</version>               <type>jar</type>               <scope>compile</scope>           </dependency>            <dependency>               <groupid>org.hibernate</groupid>               <artifactid>hibernate-core</artifactid>               <version>3.6.0.final</version>           </dependency>           <dependency>               <groupid>org.slf4j</groupid>               <artifactid>slf4j-log4j12</artifactid>               <version>1.6.5</version>           </dependency>            <dependency>               <groupid>javassist</groupid>               <artifactid>javassist</artifactid>               <version>3.12.1.ga</version>           </dependency>           <dependency>              <groupid>org.apache.poi</groupid>              <artifactid>poi</artifactid>              <version>3.10.1</version>          </dependency>       </dependencies> </project> 

keep dependency poi

    <dependency>         <groupid>org.apache.poi</groupid>         <artifactid>poi</artifactid>         <version>3.10.1</version>     </dependency> 

you don't have properies spring.version in pom, make test

   <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-orm</artifactid>         <version>2.5.6</version>     </dependency> 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -