如何在已完成的Vaadin项目上启动一个Hilla项目。

huangapple go评论74阅读模式
英文:

how to start a hilla project on an arleady finished vaadin Project

问题

这是我的pom文件目前的内容:

<repositories>
    <!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. -->

    <!-- Main Maven repository -->
    <repository>
        <id>central</id>
        <url>https://repo.maven.apache.org/maven2</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>vaadin-prereleases</id>
        <url>
            https://maven.vaadin.com/vaadin-prereleases/
        </url>
    </repository>
    <!-- Repository used by many Vaadin add-ons -->
    <repository>
        <id>Vaadin Directory</id>
        <url>https://maven.vaadin.com/vaadin-addons</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<pluginRepositories>
    <!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. -->
    <pluginRepository>
        <id>central</id>
        <url>https://repo.maven.apache.org/maven2</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>vaadin-prereleases</id>
        <url>
            https://maven.vaadin.com/vaadin-prereleases/
        </url>
    </pluginRepository>
</pluginRepositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <version>${vaadin.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.vaadin</groupId>
        <!-- Replace artifactId with vaadin-core to use only free components -->
        <artifactId>vaadin</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <!-- ###################### DRIVER ####################### -->

    <!--
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql5.version}</version>
        <!--
        <scope>runtime</scope>
        -->
    </dependency>

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>${sqlserver.version}</version>
    </dependency>

    <!-- ############################################## -->
    <!-- TOMCAT BOOT -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- spring framework -->

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-testbench</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- Include JUnit 4 support for TestBench and others -->
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

希望这有所帮助。如果您有任何其他问题,请随时提出。

英文:

Pretty much the title, i have a Vaadin-SpringBoot project already fit with the frontend in vaadin.
My goal is to install Hilla and try React or Lit.
how could i do that?

I have looked in the documentation all i could found is how to start a Hilla project from scratch that would not do because we already have all the spring application up and running, we just want to experiment with the frontEnd a little.

is it possibile?

This is my pom so far:
`<repositories>
<!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. -->

    &lt;!-- Main Maven repository --&gt;
&lt;repository&gt;
&lt;id&gt;central&lt;/id&gt;
&lt;url&gt;https://repo.maven.apache.org/maven2&lt;/url&gt;
&lt;snapshots&gt;
&lt;enabled&gt;false&lt;/enabled&gt;
&lt;/snapshots&gt;
&lt;/repository&gt;
&lt;repository&gt;
&lt;id&gt;vaadin-prereleases&lt;/id&gt;
&lt;url&gt;
https://maven.vaadin.com/vaadin-prereleases/
&lt;/url&gt;
&lt;/repository&gt;
&lt;!-- Repository used by many Vaadin add-ons --&gt;
&lt;repository&gt;
&lt;id&gt;Vaadin Directory&lt;/id&gt;
&lt;url&gt;https://maven.vaadin.com/vaadin-addons&lt;/url&gt;
&lt;snapshots&gt;
&lt;enabled&gt;false&lt;/enabled&gt;
&lt;/snapshots&gt;
&lt;/repository&gt;
&lt;/repositories&gt;
&lt;pluginRepositories&gt;
&lt;!-- The order of definitions matters. Explicitly defining central here to make sure it has the highest priority. --&gt;
&lt;pluginRepository&gt;
&lt;id&gt;central&lt;/id&gt;
&lt;url&gt;https://repo.maven.apache.org/maven2&lt;/url&gt;
&lt;snapshots&gt;
&lt;enabled&gt;false&lt;/enabled&gt;
&lt;/snapshots&gt;
&lt;/pluginRepository&gt;
&lt;pluginRepository&gt;
&lt;id&gt;vaadin-prereleases&lt;/id&gt;
&lt;url&gt;
https://maven.vaadin.com/vaadin-prereleases/
&lt;/url&gt;
&lt;/pluginRepository&gt;
&lt;/pluginRepositories&gt;
&lt;dependencyManagement&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.vaadin&lt;/groupId&gt;
&lt;artifactId&gt;vaadin-bom&lt;/artifactId&gt;
&lt;version&gt;${vaadin.version}&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;scope&gt;import&lt;/scope&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;/dependencyManagement&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.vaadin&lt;/groupId&gt;
&lt;!-- Replace artifactId with vaadin-core to use only free components --&gt;
&lt;artifactId&gt;vaadin&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.vaadin&lt;/groupId&gt;
&lt;artifactId&gt;vaadin-spring-boot-starter&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;!-- ###################### DRIVER ####################### --&gt;
&lt;!--
&lt;dependency&gt;
&lt;groupId&gt;org.postgresql&lt;/groupId&gt;
&lt;artifactId&gt;postgresql&lt;/artifactId&gt;
&lt;scope&gt;runtime&lt;/scope&gt;
&lt;/dependency&gt;
--&gt;
&lt;dependency&gt;
&lt;groupId&gt;mysql&lt;/groupId&gt;
&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
&lt;version&gt;${mysql5.version}&lt;/version&gt;
&lt;!--&lt;scope&gt;runtime&lt;/scope&gt;--&gt;
&lt;/dependency&gt;   
&lt;dependency&gt;
&lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
&lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
&lt;version&gt;${sqlserver.version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- ############################################## --&gt;
&lt;!-- TOMCAT BOOT --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;!-- spring framework --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-validation&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
&lt;optional&gt;true&lt;/optional&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.vaadin&lt;/groupId&gt;
&lt;artifactId&gt;vaadin-testbench&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;!-- Include JUnit 4 support for TestBench and others --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
&lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;groupId&gt;org.hamcrest&lt;/groupId&gt;
&lt;artifactId&gt;hamcrest-core&lt;/artifactId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;io.github.bonigarcia&lt;/groupId&gt;
&lt;artifactId&gt;webdrivermanager&lt;/artifactId&gt;
&lt;version&gt;5.1.1&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;`

Thanks for the time you given me i really need some help

答案1

得分: 1

如果您有一个相对较新的Vaadin应用程序,您应该能够在您的pom.xml中添加Hilla依赖项。

将版本添加到<properties>部分。这有助于您以后更改版本:

<hilla.version>2.1.0</hilla.version>

<dependencyManagement>部分添加"bill of material":

<dependency>
    <groupId>dev.hilla</groupId>
    <artifactId>hilla-bom</artifactId>
    <version>${hilla.version}</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>

现在,您可以在<dependencies>中包含实际的Hilla依赖项:

<dependency>
    <groupId>dev.hilla</groupId>
    <artifactId>hilla</artifactId>
</dependency>

最后一步是将插件添加到<build> > <plugins>部分:

<plugin>
    <groupId>dev.hilla</groupId>
    <artifactId>hilla-maven-plugin</artifactId>
    <version>${hilla.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-frontend</goal>
            </goals>
        </execution>
    </executions>
</plugin>

这是来自start.vaadin.com的示例,您可以用作起点,如果您想从头开始或浏览源代码。

英文:

If you have a fairly recent Vaadin application you should be able to add Hilla dependencies in your pom.xml.

Add the version into &lt;properties&gt; section. This helps you to change the version later:

&lt;hilla.version&gt;2.1.0&lt;/hilla.version&gt;

In the &lt;dependencyManagement&gt; section add the "bill of material":

&lt;dependency&gt;
&lt;groupId&gt;dev.hilla&lt;/groupId&gt;
&lt;artifactId&gt;hilla-bom&lt;/artifactId&gt;
&lt;version&gt;${hilla.version}&lt;/version&gt;
&lt;type&gt;pom&lt;/type&gt;
&lt;scope&gt;import&lt;/scope&gt;
&lt;/dependency&gt;

Now you can include actual Hilla dependency in &lt;dependencies&gt; using:

&lt;dependency&gt;
&lt;groupId&gt;dev.hilla&lt;/groupId&gt;
&lt;artifactId&gt;hilla&lt;/artifactId&gt;
&lt;/dependency&gt;

Last thing is to add the plugin into &lt;build&gt; > &lt;plugins&gt; section:

&lt;plugin&gt;
&lt;groupId&gt;dev.hilla&lt;/groupId&gt;
&lt;artifactId&gt;hilla-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;${hilla.version}&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;goals&gt;
&lt;goal&gt;prepare-frontend&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;

Here is an example from start.vaadin.com you can use for a starting point, if you want to starts from scratch or browse the source code.

huangapple
  • 本文由 发表于 2023年6月13日 17:12:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76463353.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定